<commit_before>// DefaultAssociative.chpl
//
pragma "no use ChapelStandard"
module DefaultAssociative {

use DSIUtil;
config param debugDefaultAssoc = false;
config param debugAssocDataPar = false;

use Sort /* only QuickSort */;

// TODO: make the domain parameterized by this?
type chpl_table_index_type = int;


/* These declarations could/should both be nested within
   DefaultAssociativeDom? */
enum chpl__hash_status { empty, full, deleted };

record chpl_TableEntry {
  type idxType;
  var status: chpl__hash_status = chpl__hash_status.empty;
  var idx: idxType;
}

proc chpl__primes return (23, 53, 97, 193, 389, 769, 1543,
                         3079, 6151, 12289, 24593, 49157, 98317, 196613,
                         393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843,
                         50331653, 100663319, 201326611, 402653189, 805306457, 1610612741);

class DefaultAssociativeDom: BaseAssociativeDom {
  type idxType;
  param parSafe: bool;

  var dist: DefaultDist;

  // The guts of the associative domain
  var numEntries: atomic chpl_table_index_type;
  var tableLock: atomic bool; // do not access directly, use function below
  var tableSizeNum = 1;
  var tableSize = chpl__primes(tableSizeNum);
  var tableDom = {0..tableSize-1};
  var table: [tableDom] chpl_TableEntry(idxType);

  inline proc lockTable() {
    while tableLock.testAndSet() do chpl_task_yield();
  }<commit_msg>Change the atomics used in DefaultAssociativeDom into explicit processor atomics<commit_after>// DefaultAssociative.chpl
//
pragma "no use ChapelStandard"
module DefaultAssociative {

use DSIUtil;
config param debugDefaultAssoc = false;
config param debugAssocDataPar = false;

use Sort /* only QuickSort */;

// TODO: make the domain parameterized by this?
type chpl_table_index_type = int;


/* These declarations could/should both be nested within
   DefaultAssociativeDom? */
enum chpl__hash_status { empty, full, deleted };

record chpl_TableEntry {
  type idxType;
  var status: chpl__hash_status = chpl__hash_status.empty;
  var idx: idxType;
}

proc chpl__primes return (23, 53, 97, 193, 389, 769, 1543,
                         3079, 6151, 12289, 24593, 49157, 98317, 196613,
                         393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843,
                         50331653, 100663319, 201326611, 402653189, 805306457, 1610612741);

class DefaultAssociativeDom: BaseAssociativeDom {
  type idxType;
  param parSafe: bool;

  var dist: DefaultDist;

  // The guts of the associative domain

  // We explicitly use processor atomics here since this is not
  // by design a distributed data structure
  var numEntries: atomic_int64;
  var tableLock: atomicflag; // do not access directly, use function below
  var tableSizeNum = 1;
  var tableSize = chpl__primes(tableSizeNum);
  var tableDom = {0..tableSize-1};
  var table: [tableDom] chpl_TableEntry(idxType);

  inline proc lockTable() {
    while tableLock.testAndSet() do chpl_task_yield();
  }
{'fraction_non_alphanumeric': 0.08197267577474175, 'fraction_numerical': 0.10663112295901367, 'mean_word_length': 3.6687402799377917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4643140', 'n_tokens_mistral': 1185, 'n_tokens_neox': 941, 'n_words': 299}