<commit_before>#ifndef _chplcomm_h_
#define _chplcomm_h_

#ifndef LAUNCHER

#include <stdint.h>
#include <chplcomm_md.h>
#include "chplcomm_locales.h"
#include "chpltypes.h"

extern int32_t chpl_localeID; // unique ID for each locale: 0, 1, 2, ...
extern int32_t chpl_numLocales; // number of locales

extern int32_t chpl_numPrivateObjects;
extern void** chpl_privateObjects; // privatized array and domain objects

#define chpl_numPrivatizedClasses() chpl_numPrivateObjects
extern void chpl_newPrivatizedClass(void*);
extern void* chpl_getPrivatizedClass(int32_t);


extern void chpl__heapAllocateGlobals(void);

extern const int chpl_numGlobalsOnHeap;
extern void** chpl_globals_registry;
extern void* chpl_globals_registry_static[];

//
// Multi-locale macros
//
// Note: Macros starting with CHPL_COMM involve some kind of communication
//

#define CHPL_WIDEN(wide, ref)                   \
  do {                                          \
    (wide).locale = chpl_localeID;                  \
    (wide).addr = (ref);                        \
  } while (0)

#define CHPL_WIDEN_NULL(wide)                   \
  do {                                          \
    (wide).locale = 0;                          \
    (wide).addr = NULL;                         \
  } while (0)

#define CHPL_WIDEN_STRING(wide, str)                                    \
  do {                                                                  \
    const char* chpl_macro_tmp = str;                                   \
    size_t chpl_macro_len = strlen(chpl_macro_tmp) + 1;                 \
    (wide).locale = chpl_localeID;                                      \
    (wide).addr = chpl_malloc(chpl_macro_len, sizeof(char),             \
                              CHPL_RT_MD_SET_WIDE_STRING, 0, 0);        \
    strncpy((char*)(wide).addr, chpl_macro_tmp, chpl_macro_len);        \
    (wide).size = chpl_macro_len;                                       \
  } while (0)

#define CHPL_NARROW(ref, wide)                  \
  (ref) = (wide).addr

#define CHPL_WIDE_TEST_NEQ(wide1, wide2)                                \
  (((wide1).addr != (wide2).addr) ||                                    \
   (((wide1).addr != 0) && ((wide1).locale != (wide2).locale)))

#define CHPL_WIDE_TEST_EQ(wide1, wide2)         \
  (!CHPL_WIDE_TEST_NEQ(wide1, wide2))

#define CHPL_WIDE_CAST(wide1, type, wide2)                              \
  do {                                                                  \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = (type)((wide2).addr);                                \
  } while (0)

#define CHPL_COMM_WIDE_DYNAMIC_CAST(wide1, type, cond, wide2, ln, fn)   \
  do {                                                                  \
    chpl__class_id chpl_macro_tmp;                                      \
    CHPL_COMM_WIDE_GET_FIELD_VALUE(chpl_macro_tmp,                      \
                                   wide2, object, chpl__cid, chpl__class_id, ln, fn);   \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = (cond) ? (type)((wide2).addr) : NULL;                \
  } while (0)

#define CHPL_WIDE_GET_PRIVATIZED_CLASS(wide, id)                        \
  do {                                                                  \
    (wide).locale = chpl_localeID;                                          \
    (wide).addr = chpl_getPrivatizedClass(id);                          \
  } while (0)

// Enable to support hybrid computing
#define CHPL_COMM_HETEROGENEOUS


#ifdef CHPL_COMM_HETEROGENEOUS
extern chpl_fieldType chpl_structType[][9];
#define SPECIFY_SIZE(type) chpl_rt_type_id_##type
#define SPECIFY_STRING_SIZE(size) (chpl_error("unhandled case", 0, 0),0)
#define GET_TYPE(record, field) (chpl_structType[record][field]).type
#define GET_OFFSET(record, field) (chpl_structType[record][field]).offset
#else
#define SPECIFY_SIZE(type) (/*printf("%s\n", "chpl_rt_type_id_" #type),*//*chpl_rt_type_id_##type,*/sizeof(type))
#define SPECIFY_STRING_SIZE(size) (size)
#endif


#define CHPL_COMM_WIDE_GET(local, wide, type, ln, fn)                   \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = *(wide).addr;                                             \
    else                                                                \
      chpl_comm_get(&(local), (wide).locale, (wide).addr,               \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_GET_LOCALE(local, wide, ln, fn)                  \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = (wide).addr->locale;                                      \
    else                                                                \
      chpl_comm_get(&(local), (wide).locale, (wide).addr,               \
                    SPECIFY_SIZE(int32_t), ln, fn);                     \
  } while (0)

#define CHPL_COMM_WIDE_PUT(type, wide, local, ln, fn)                   \
  do {                                                                  \
    type chpl_macro_tmp2 = local;                                       \
    if (chpl_localeID == (wide).locale)                                 \
      *(wide).addr = chpl_macro_tmp2;                                   \
    else                                                                \
      chpl_comm_put(&chpl_macro_tmp2, (wide).locale,                    \
                    (wide).addr, SPECIFY_SIZE(type), ln, fn);           \
  } while (0)

#define CHPL_COMM_WIDE_GET_STRING(local, wide, ln, fn)                  \
  do {                                                                  \
    char* chpl_macro_tmp = chpl_malloc((wide).size,                     \
                                       sizeof(char),                    \
                                       CHPL_RT_MD_GET_WIDE_STRING,      \
                                       -1, "<internal>");               \
    if (chpl_localeID == (wide).locale)                                 \
      memcpy(chpl_macro_tmp, (wide).addr, (wide).size);                 \
    else                                                                \
      chpl_comm_get(chpl_macro_tmp, (wide).locale,                      \
                    (void*)((wide).addr), SPECIFY_STRING_SIZE((wide).size), ln, fn); \
    local = chpl_macro_tmp;                                             \
  } while (0)

#define CHPL_WIDE_GET_FIELD(wide1, wide2, stype, sfield)                \
  do {                                                                  \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = &((stype)((wide2).addr))->sfield;                    \
  } while (0)

#define CHPL_COMM_WIDE_GET_FIELD_VALUE(local, wide, stype, sfield, type, ln, fn) \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = ((stype)((wide).addr))->sfield;                           \
    else                                                                \
      chpl_comm_get(&(local),                                           \
                    (wide).locale,                                      \
                    &((stype)((wide).addr))->sfield,                    \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_SET_FIELD_VALUE(type, wide, local, stype, sfield, ln, fn) \
  do {                                                                  \
    type chpl_macro_tmp = local;                                        \
    if (chpl_localeID == (wide).locale)                                 \
      ((stype)((wide).addr))->sfield = chpl_macro_tmp;                  \
    else                                                                \
      chpl_comm_put(&chpl_macro_tmp,                                    \
                    (wide).locale,                                      \
                    &((stype)((wide).addr))->sfield,                    \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_ARRAY_GET(wide, cls, ind, stype, sfield, etype, ln, fn) \
  do {                                                                  \
    (wide).locale = (cls).locale;                                       \
    CHPL_COMM_WIDE_GET_FIELD_VALUE((wide).addr, cls, stype, sfield, etype, ln, fn); \
    (wide).addr += ind;                                                 \
  } while (0)

#define CHPL_COMM_WIDE_ARRAY_GET_VALUE(wide_type, local, cls, ind, stype, sfield, etype, ln, fn) \
  do {                                                                  \
    wide_type chpl_macro_tmp;                                           \
    CHPL_COMM_WIDE_ARRAY_GET(chpl_macro_tmp, cls, ind, stype, sfield, etype, ln, fn); \
    CHPL_COMM_WIDE_GET(local, chpl_macro_tmp, stype, ln, fn);           \
  } while (0)<commit_msg>Oops -- forgot this file<commit_after>#ifndef _chplcomm_h_
#define _chplcomm_h_

#ifndef LAUNCHER

#include <stdint.h>
#include <chplcomm_md.h>
#include "chplcomm_locales.h"
#include "chpltypes.h"

extern int32_t chpl_localeID; // unique ID for each locale: 0, 1, 2, ...
extern int32_t chpl_numLocales; // number of locales

extern int32_t chpl_numPrivateObjects;
extern void** chpl_privateObjects; // privatized array and domain objects

#define chpl_numPrivatizedClasses() chpl_numPrivateObjects
extern void chpl_newPrivatizedClass(void*);
extern void* chpl_getPrivatizedClass(int32_t);


extern void chpl__heapAllocateGlobals(void);

extern const int chpl_numGlobalsOnHeap;
extern void** chpl_globals_registry;
extern void* chpl_globals_registry_static[];

//
// Multi-locale macros
//
// Note: Macros starting with CHPL_COMM involve some kind of communication
//

#define CHPL_WIDEN(wide, ref)                   \
  do {                                          \
    (wide).locale = chpl_localeID;                  \
    (wide).addr = (ref);                        \
  } while (0)

#define CHPL_WIDEN_NULL(wide)                   \
  do {                                          \
    (wide).locale = 0;                          \
    (wide).addr = NULL;                         \
  } while (0)

#define CHPL_WIDEN_STRING(wide, str)                                    \
  do {                                                                  \
    const char* chpl_macro_tmp = str;                                   \
    size_t chpl_macro_len = strlen(chpl_macro_tmp) + 1;                 \
    (wide).locale = chpl_localeID;                                      \
    (wide).addr = chpl_malloc(chpl_macro_len, sizeof(char),             \
                              CHPL_RT_MD_SET_WIDE_STRING, 0, 0);        \
    strncpy((char*)(wide).addr, chpl_macro_tmp, chpl_macro_len);        \
    (wide).size = chpl_macro_len;                                       \
  } while (0)

#define CHPL_NARROW(ref, wide)                  \
  (ref) = (wide).addr

#define CHPL_WIDE_TEST_NEQ(wide1, wide2)                                \
  (((wide1).addr != (wide2).addr) ||                                    \
   (((wide1).addr != 0) && ((wide1).locale != (wide2).locale)))

#define CHPL_WIDE_TEST_EQ(wide1, wide2)         \
  (!CHPL_WIDE_TEST_NEQ(wide1, wide2))

#define CHPL_WIDE_CAST(wide1, type, wide2)                              \
  do {                                                                  \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = (type)((wide2).addr);                                \
  } while (0)

#define CHPL_COMM_WIDE_DYNAMIC_CAST(wide1, type, cond, wide2, ln, fn)   \
  do {                                                                  \
    chpl__class_id chpl_macro_tmp;                                      \
    CHPL_COMM_WIDE_GET_FIELD_VALUE(chpl_macro_tmp,                      \
                                   wide2, object, chpl__cid, chpl__class_id, ln, fn);   \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = (cond) ? (type)((wide2).addr) : NULL;                \
  } while (0)

#define CHPL_WIDE_GET_PRIVATIZED_CLASS(wide, id)                        \
  do {                                                                  \
    (wide).locale = chpl_localeID;                                          \
    (wide).addr = chpl_getPrivatizedClass(id);                          \
  } while (0)

// Enable to support hybrid computing
#define CHPL_COMM_HETEROGENEOUS


#ifdef CHPL_COMM_HETEROGENEOUS
extern chpl_fieldType chpl_structType[][9];
#define SPECIFY_SIZE(type) chpl_rt_type_id_##type
#define SPECIFY_STRING_SIZE(size) (chpl_error("unhandled case", 0, 0),0)
#define GET_TYPE(record, field) (chpl_structType[record][field]).type
#define GET_OFFSET(record, field) (chpl_structType[record][field]).offset
#else
#define SPECIFY_SIZE(type) (/*printf("%s\n", "chpl_rt_type_id_" #type),*//*chpl_rt_type_id_##type,*/sizeof(type))
#define SPECIFY_STRING_SIZE(size) (size)
#endif


#define CHPL_COMM_WIDE_GET(local, wide, type, ln, fn)                   \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = *(wide).addr;                                             \
    else                                                                \
      chpl_comm_get(&(local), (wide).locale, (wide).addr,               \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_GET_LOCALE(local, wide, ln, fn)                  \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = (wide).addr->locale;                                      \
    else                                                                \
      chpl_comm_get(&(local), (wide).locale, (wide).addr,               \
                    SPECIFY_SIZE(int32_t), ln, fn);                     \
  } while (0)

#define CHPL_COMM_WIDE_PUT(type, wide, local, ln, fn)                   \
  do {                                                                  \
    type chpl_macro_tmp2 = local;                                       \
    if (chpl_localeID == (wide).locale)                                 \
      *(wide).addr = chpl_macro_tmp2;                                   \
    else                                                                \
      chpl_comm_put(&chpl_macro_tmp2, (wide).locale,                    \
                    (wide).addr, SPECIFY_SIZE(type), ln, fn);           \
  } while (0)

#define CHPL_COMM_WIDE_GET_STRING(local, wide, ln, fn)                  \
  do {                                                                  \
    char* chpl_macro_tmp = chpl_malloc((wide).size,                     \
                                       sizeof(char),                    \
                                       CHPL_RT_MD_GET_WIDE_STRING,      \
                                       -1, "<internal>");               \
    if (chpl_localeID == (wide).locale)                                 \
      memcpy(chpl_macro_tmp, (wide).addr, (wide).size);                 \
    else                                                                \
      chpl_comm_get(chpl_macro_tmp, (wide).locale,                      \
                    (void*)((wide).addr), SPECIFY_STRING_SIZE((wide).size), ln, fn); \
    local = chpl_macro_tmp;                                             \
  } while (0)

#define CHPL_WIDE_GET_FIELD(wide1, wide2, stype, sfield)                \
  do {                                                                  \
    (wide1).locale = (wide2).locale;                                    \
    (wide1).addr = &((stype)((wide2).addr))->sfield;                    \
  } while (0)

#define CHPL_COMM_WIDE_GET_FIELD_VALUE(local, wide, stype, sfield, type, ln, fn) \
  do {                                                                  \
    if (chpl_localeID == (wide).locale)                                 \
      local = ((stype)((wide).addr))->sfield;                           \
    else                                                                \
      chpl_comm_get(&(local),                                           \
                    (wide).locale,                                      \
                    &((stype)((wide).addr))->sfield,                    \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_SET_FIELD_VALUE(type, wide, local, stype, sfield, ln, fn) \
  do {                                                                  \
    type chpl_macro_tmp = local;                                        \
    if (chpl_localeID == (wide).locale)                                 \
      ((stype)((wide).addr))->sfield = chpl_macro_tmp;                  \
    else                                                                \
      chpl_comm_put(&chpl_macro_tmp,                                    \
                    (wide).locale,                                      \
                    &((stype)((wide).addr))->sfield,                    \
                    SPECIFY_SIZE(type), ln, fn);                        \
  } while (0)

#define CHPL_COMM_WIDE_ARRAY_GET(wide, cls, ind, stype, sfield, etype, ln, fn) \
  do {                                                                  \
    (wide).locale = (cls).locale;                                       \
    CHPL_COMM_WIDE_GET_FIELD_VALUE((wide).addr, cls, stype, sfield, etype, ln, fn); \
    (wide).addr += ind;                                                 \
  } while (0)

#define CHPL_COMM_WIDE_ARRAY_GET_VALUE(wide_type, local, cls, ind, stype, sfield, etype, etype2, ln, fn) \
  do {                                                                  \
    wide_type chpl_macro_tmp;                                           \
    CHPL_COMM_WIDE_ARRAY_GET(chpl_macro_tmp, cls, ind, stype, sfield, etype, ln, fn); \
    CHPL_COMM_WIDE_GET(local, chpl_macro_tmp, etype2, ln, fn);           \
  } while (0)
{'fraction_non_alphanumeric': 0.10074225473321859, 'fraction_numerical': 0.00774526678141136, 'mean_word_length': 0.9666807700444257, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 172, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6313974', 'n_tokens_mistral': 5185, 'n_tokens_neox': 4945, 'n_words': 869}