Beispiel #1
0
void chpl_printMemStat(int32_t lineno, c_string filename) {
  if (!chpl_memTrack)
    chpl_error("invalid call to printMemStat(); rerun with --memTrack",
               lineno, filename);
  chpl_sync_lock(&memTrack_sync);
  fprintf(memLogFile, "=================\n");
  fprintf(memLogFile, "Memory Statistics\n");
  if (chpl_numNodes == 1) {
    fprintf(memLogFile, "==============================================================\n");
    fprintf(memLogFile, "Current Allocated Memory               %zd\n", totalMem);
    fprintf(memLogFile, "Maximum Simultaneous Allocated Memory  %zd\n", maxMem);
    fprintf(memLogFile, "Total Allocated Memory                 %zd\n", totalAllocated);
    fprintf(memLogFile, "Total Freed Memory                     %zd\n", totalFreed);
    fprintf(memLogFile, "==============================================================\n");
  } else {
    int i;
    fprintf(memLogFile, "==============================================================\n");
    fprintf(memLogFile, "Locale\n");
    fprintf(memLogFile, "           Current Allocated Memory\n");
    fprintf(memLogFile, "                      Maximum Simultaneous Allocated Memory\n");
    fprintf(memLogFile, "                                 Total Allocated Memory\n");
    fprintf(memLogFile, "                                            Total Freed Memory\n");
    fprintf(memLogFile, "==============================================================\n");
    for (i = 0; i < chpl_numNodes; i++) {
      static size_t m1, m2, m3, m4;
      chpl_gen_comm_get(&m1, i, &totalMem, sizeof(size_t), -1 /* broke for hetero */, 1, lineno, filename);
      chpl_gen_comm_get(&m2, i, &maxMem, sizeof(size_t), -1 /* broke for hetero */, 1, lineno, filename);
      chpl_gen_comm_get(&m3, i, &totalAllocated,  sizeof(size_t), -1 /* broke for hetero */, 1, lineno, filename);
      chpl_gen_comm_get(&m4, i, &totalFreed, sizeof(size_t), -1 /*broke for hetero */, 1, lineno, filename);
      fprintf(memLogFile, "%-9d  %-9zu  %-9zu  %-9zu  %-9zu\n", i, m1, m2, m3, m4);
    }
    fprintf(memLogFile, "==============================================================\n");
  }
  chpl_sync_unlock(&memTrack_sync);
}
Beispiel #2
0
// The initial ref count in the return qbytes buffer is 1.
// The caller is responsible for calling qbytes_release on it when done.
qbytes_t* bulk_get_bytes(int64_t src_locale, qbytes_t* src_addr)
{
  qbytes_t tmp;
  qbytes_t* ret;
  int64_t src_len;
  void* src_data;
  qioerr err;

  // Zero-initialize tmp.
  memset(&tmp, 0, sizeof(qbytes_t));

  // First, get the length and local pointer to the bytes.
  chpl_gen_comm_get( &tmp, src_locale, src_addr, sizeof(qbytes_t), CHPL_TYPE_int64_t, -1, "<internal>");
  src_len = tmp.len;
  src_data = tmp.data;

  // The initial ref count is 1.
  err = qbytes_create_calloc(&ret, src_len);
  if( err ) return NULL;

  // TODO -- note -- technically, this should be gasnet_get_bulk,
  // since we don't want to require src/dst to have a particular alignment.

  // Next, get the data itself.
  if( src_data ) {
    chpl_gen_comm_get( ret->data, src_locale, src_data, sizeof(uint8_t)*src_len, CHPL_TYPE_uint8_t, -1, "<internal>");
  }

  // Great! All done.
  return ret; 
}
Beispiel #3
0
/* This function returns a string from src_locale located at src_addr.
 *
 *     src_locale: node id
 *     src_addr: string address on remote node
 *     src_len: length
 *
 */
c_string_copy remoteStringCopy(c_nodeid_t src_locale,
                               c_string src_addr, int64_t src_len,
                               int32_t lineno, c_string filename) {
  char* ret;
  if (src_addr == NULL) return NULL;
  ret = chpl_mem_alloc(src_len+1, CHPL_RT_MD_STRING_COPY_REMOTE,
                       lineno, filename);
  chpl_gen_comm_get((void*)ret, src_locale, (void*)src_addr, sizeof(char),
                    CHPL_TYPE_uint8_t, src_len+1, lineno, filename);
  return (c_string)ret;
}
Beispiel #4
0
qbytes_t* bulk_get_bytes(int64_t src_locale, qbytes_t* src_addr)
{
  qbytes_t* ret;
  int64_t src_len;
  err_t err;

  // First, get the length of the bytes.
  chpl_gen_comm_get( &src_len, src_locale, & src_addr->len, sizeof(int64_t), CHPL_TYPE_int64_t, 1, -1, "<internal>");
//  chpl_comm_get

  err = qbytes_create_calloc(&ret, src_len);
  if( err ) return NULL;


  // TODO -- note -- technically, this should be gasnet_get_bulk,
  // since we don't want to require src/dst to have a particular alignment.

  // Next, get the data itself.
  chpl_gen_comm_get( ret->data, src_locale, & src_addr->data, sizeof(uint8_t), CHPL_TYPE_uint8_t, src_len, -1, "<internal>");

  // Great! All done.
  return ret; 
}
Beispiel #5
0
void chpl_gmp_get_mpz(mpz_t ret, int64_t src_locale, __mpz_struct from) {
  // First, resize our destination appropriately.
  mpz_realloc2(ret, from._mp_alloc * mp_bits_per_limb);

  // Copy the _alloc and _size fields.
  ret[0]._mp_alloc = from._mp_alloc;
  ret[0]._mp_size  = from._mp_size;

  // Next, use GASNET to move the pointer data.
  chpl_gen_comm_get(ret[0]._mp_d,
                    src_locale,
                    from._mp_d,
                    sizeof(mp_limb_t) * ret[0]._mp_alloc,
                    CHPL_TYPE_uint64_t,
                    CHPL_COMM_UNKNOWN_ID,
                    0,
                    0);
}
Beispiel #6
0
// un-macro'd CHPL_COMM_WIDE_GET_STRING
void
chpl_comm_wide_get_string(chpl_string* local, struct chpl_chpl____wide_chpl_string_s* x, int32_t tid, int32_t lineno, chpl_string filename)
{
  char* chpl_macro_tmp;

  if (x->addr == NULL)
  {
    *local = NULL;
    return;
  }

  chpl_macro_tmp =
      chpl_mem_calloc(x->size, CHPL_RT_MD_GET_WIDE_STRING, lineno, filename);
  if (chpl_nodeID == chpl_rt_nodeFromLocaleID(x->locale))
    chpl_memcpy(chpl_macro_tmp, x->addr, x->size);
  else
    chpl_gen_comm_get((void*) &(*chpl_macro_tmp),
                  chpl_rt_nodeFromLocaleID(x->locale),
                  (void*)(x->addr),
                  sizeof(char), tid, x->size, lineno, filename);
  *local = chpl_macro_tmp;
}
Beispiel #7
0
// This copies the remote string data into a local wide string representation
// of the same.
// This routine performs a deep copy of the character array data 
// after fetching the string descriptor from the remote node.  (The char*
// field in the local copy of the remote descriptor has no meaning in the 
// context of the local node, since it refers to elements in the address 
// space on the remote node.)  
// In chpl_comm_wide_get_string() a buffer of the right size is allocated 
// to receive the bytes copied from the remote node.  This buffer will be leaked,
// since no corresponding free is added to the generated code.
void chpl_gen_comm_wide_string_get(void *addr, c_nodeid_t node, void *raddr,
                                   size_t size, int32_t typeIndex,
                                   int ln, int32_t fn) {
  // This part just copies the descriptor.
  if (chpl_nodeID == node) {
    chpl_memcpy(addr, raddr, size);
  } else {
    chpl_gen_comm_get(addr, node, raddr, size, typeIndex, ln, fn);
  }

  // And now we copy the bytes in the string itself.
  {
    struct chpl_chpl____wide_chpl_string_s* local_str =
      (struct chpl_chpl____wide_chpl_string_s*) addr;
    // Accessing the addr field of the incomplete struct declaration
    // would not work in this context except that this function
    // is always inlined.
    chpl_comm_wide_get_string((chpl_string*) &(local_str->addr),
                              local_str, typeIndex, ln, fn);
    // The bytes live locally, so we have to update the locale.
    local_str->locale = chpl_gen_getLocaleID();
  }
}