<commit_before>module analyze_RMAT_graph_associative_array {

  //
  // If graphInputFile != "", read in the graph from the files with
  // that prefix; do not run edge generation or Kernel 1.
  // Otherwise, if graphOutputFile != "" then write out the graph
  // generated by edge generation and Kernel 1 into those files.
  //
  // The *DStyle strings control the debugging printouts during I/O.
  // See interpretDStyle() for details.
  //
  // If graphVerifyFile != "" and the graph was read from graphInputFile,
  // write it out to graphVerifyFile. Could be used for correctness checking.
  //
  // The graph size in graphInputFile must match the SCALE config constant.
  //
  config const graphInputFile    = "";
  config const graphInputDStyle  = "-";
  config const graphOutputFile   = "";
  config const graphOutputDStyle = "-";
  config const graphVerifyFile   = "";
  config const graphVerifyDStyle = "-";

  // used during graph allocation
  config const initialRMATNeighborListLength =
    if graphInputFile == "" then 16 else 0;
  param initialFirstAvail = 1;

    //
    // We will represent the neighbor list as an array of nleType.
    // nle = Neighbor List Element.
    //
    type nleType = (int(64), int(64));
    // Extract each component from a neighbor.
    proc nleNID(nlElm: nleType)    return nlElm(1);
    proc nleWeight(nlElm: nleType) return nlElm(2);
    // Mark a use of a neighbor as a pair.
    proc nleAsPair(nlElm: nleType) return nlElm;
    // Produce a neighbor from components.
    proc nleMake(nID: int(64), wt: int(64)): nleType  return (nID, wt);

    //
    // VertexData: stores the neighbor list of a vertex.
    //
    record VertexData {
      var ndom = [initialFirstAvail..initialRMATNeighborListLength];
      var neighborList: [ndom] nleType;

      proc numNeighbors()  return ndom.numIndices;

      // firstAvail$ must be passed by reference
      proc addEdgeOnVertex(uArg, vArg, wArg, firstAvail$: sync int) {
        on this do {
          // todo: the compiler should make these values local automatically!
          const /*u = uArg,*/ v = vArg, w = wArg;
          local {
            // lock the vertex
            const edgePos = firstAvail$;

            const prevNdomLen = ndom.high;
            if edgePos > prevNdomLen {
              // grow our arrays, by 2x
              // statistics: growCount += 1;
              ndom = [1..prevNdomLen * 2];
              // bounds checking below will ensure (edgePos <= ndom.high)
            }
            // store the edge
            neighborList[edgePos] = nleMake(v, w);

            // release the lock
            firstAvail$ = edgePos + 1;
          }
        } // on
      }

      // not parallel-safe
      proc tidyNeighbors(firstAvail$: sync int) {
        local {
          // no synchronization here
          var edgeCount = firstAvail$.readXX() - 1;
          RemoveDuplicates(1, edgeCount);
          // TODO: ideally if we don't save much memory, do not resize
          if edgeCount != ndom.numIndices {
            // statistics: shrinkCount += 1;<commit_msg>Fixed the 'local' failure in test/studies/ssca2/vass.<commit_after>module analyze_RMAT_graph_associative_array {

  //
  // If graphInputFile != "", read in the graph from the files with
  // that prefix; do not run edge generation or Kernel 1.
  // Otherwise, if graphOutputFile != "" then write out the graph
  // generated by edge generation and Kernel 1 into those files.
  //
  // The *DStyle strings control the debugging printouts during I/O.
  // See interpretDStyle() for details.
  //
  // If graphVerifyFile != "" and the graph was read from graphInputFile,
  // write it out to graphVerifyFile. Could be used for correctness checking.
  //
  // The graph size in graphInputFile must match the SCALE config constant.
  //
  config const graphInputFile    = "";
  config const graphInputDStyle  = "-";
  config const graphOutputFile   = "";
  config const graphOutputDStyle = "-";
  config const graphVerifyFile   = "";
  config const graphVerifyDStyle = "-";

  // used during graph allocation
  config const initialRMATNeighborListLength =
    if graphInputFile == "" then 16 else 0;
  param initialFirstAvail = 1;

    //
    // We will represent the neighbor list as an array of nleType.
    // nle = Neighbor List Element.
    //
    type nleType = (int(64), int(64));
    // Extract each component from a neighbor.
    proc nleNID(nlElm: nleType)    return nlElm(1);
    proc nleWeight(nlElm: nleType) return nlElm(2);
    // Mark a use of a neighbor as a pair.
    proc nleAsPair(nlElm: nleType) return nlElm;
    // Produce a neighbor from components.
    proc nleMake(nID: int(64), wt: int(64)): nleType  return (nID, wt);

    //
    // VertexData: stores the neighbor list of a vertex.
    //
    record VertexData {
      var ndom = [initialFirstAvail..initialRMATNeighborListLength];
      var neighborList: [ndom] nleType;

      proc numNeighbors()  return ndom.numIndices;

      // firstAvail$ must be passed by reference
      proc addEdgeOnVertex(uArg, vArg, wArg, firstAvail$: sync int) {
        on this do {
          // todo: the compiler should make these values local automatically!
          const /*u = uArg,*/ v = vArg, w = wArg;
            // Lock and unlock should be within 'local', but currently
            // need to pull them out due to implementation.
            // lock the vertex
            const edgePos = firstAvail$;

          local {
            const prevNdomLen = ndom.high;
            if edgePos > prevNdomLen {
              // grow our arrays, by 2x
              // statistics: growCount += 1;
              ndom = [1..prevNdomLen * 2];
              // bounds checking below will ensure (edgePos <= ndom.high)
            }
            // store the edge
            neighborList[edgePos] = nleMake(v, w);
          }

            // release the lock
            firstAvail$ = edgePos + 1;
        } // on
      }

      // not parallel-safe
      proc tidyNeighbors(firstAvail$: sync int) {
        local {
          // no synchronization here
          var edgeCount = firstAvail$.readXX() - 1;
          RemoveDuplicates(1, edgeCount);
          // TODO: ideally if we don't save much memory, do not resize
          if edgeCount != ndom.numIndices {
            // statistics: shrinkCount += 1;
{'fraction_non_alphanumeric': 0.09541804440245631, 'fraction_numerical': 0.00771532042198079, 'mean_word_length': 2.1383399209486167, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5147494', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1816, 'n_words': 643}