Ejemplo n.º 1
0
static void *ptr_array_realloc(void **a1, int rank, long *dimen, int size, int depth) {

    long length;

    void *a2;

    length = array_mem_length(rank, dimen, size);

    a2 = (void *) realloc(a1, length);
    if (a2 == NULL) {
        fprintf(stderr, "ERROR: memory allocation failed: size = %ld bytes\n", length);
        return NULL;
    }

    return ptr_array_init((void **) a2, rank - 1, dimen + 1, dimen[0]);
}
Ejemplo n.º 2
0
adlb_code
xlb_workq_init(int work_types, const xlb_layout *layout)
{
  assert(work_types >= 1);
  DEBUG("xlb_workq_init(work_types=%i)", work_types);

  adlb_code ac;

  bool ok = ptr_array_init(&wu_array, WU_ARRAY_INIT_SIZE);
  CHECK_MSG(ok, "wu_array initialisation failed");

  targeted_work_size = targeted_work_entries(work_types,
                                    layout->my_workers);
  ac = init_work_heaps(&targeted_work, targeted_work_size);
  ADLB_CHECK(ac);

  host_targeted_work_size = targeted_work_entries(work_types,
                                          layout->my_worker_hosts);
  ac = init_work_heaps(&host_targeted_work, host_targeted_work_size);
  ADLB_CHECK(ac);

  ac = init_work_heaps(&untargeted_work, work_types);
  ADLB_CHECK(ac);

  parallel_work = malloc(sizeof(parallel_work[0]) * (size_t)work_types);
  xlb_workq_parallel_task_count = 0;
  valgrind_assert(parallel_work != NULL);
  for (int i = 0; i < work_types; i++)
  {
    rbtree_init(&parallel_work[i]);
  }

  if (xlb_s.perfc_enabled)
  {
    DEBUG("PERF COUNTERS ENABLED");
    xlb_task_counters = malloc(sizeof(*xlb_task_counters) *
                               (size_t)work_types);
    valgrind_assert(xlb_task_counters != NULL);
    for (int i = 0; i < work_types; i++)
    {
      xlb_task_counters[i].targeted_enqueued = 0;
      xlb_task_counters[i].targeted_bypass = 0;
      xlb_task_counters[i].single_enqueued = 0;
      xlb_task_counters[i].single_bypass = 0;
      xlb_task_counters[i].single_stolen = 0;
      xlb_task_counters[i].parallel_enqueued = 0;
      xlb_task_counters[i].parallel_bypass = 0;
      xlb_task_counters[i].parallel_stolen = 0;

      xlb_task_counters[i].targeted_data_wait = 0;
      xlb_task_counters[i].targeted_data_no_wait = 0;
      xlb_task_counters[i].single_data_wait = 0;
      xlb_task_counters[i].single_data_no_wait = 0;
      xlb_task_counters[i].parallel_data_wait = 0;
      xlb_task_counters[i].parallel_data_no_wait = 0;
    }
  }
  else
  {
    xlb_task_counters = NULL;
  }

  return ADLB_SUCCESS;
}