예제 #1
0
static void opencl_action_finalize(
  MTAPI_IN mtapi_action_hndl_t action,
  MTAPI_OUT mtapi_status_t* status
  ) {
  mtapi_status_t local_status = MTAPI_ERR_UNKNOWN;
  cl_int err;
  EMBB_UNUSED_IN_RELEASE(err);

  if (embb_mtapi_node_is_initialized()) {
    embb_mtapi_node_t * node = embb_mtapi_node_get_instance();
    if (embb_mtapi_action_pool_is_handle_valid(node->action_pool, action)) {
      embb_mtapi_action_t * local_action =
        embb_mtapi_action_pool_get_storage_for_handle(
        node->action_pool, action);
      embb_mtapi_opencl_action_t * opencl_action =
        (embb_mtapi_opencl_action_t *)local_action->plugin_data;
      if (NULL != opencl_action->node_local_data) {
        err = clReleaseMemObject(opencl_action->node_local_data);
        assert(CL_SUCCESS == err);
      }

      err = clReleaseKernel(opencl_action->kernel);
      assert(CL_SUCCESS == err);
      err = clReleaseProgram(opencl_action->program);
      assert(CL_SUCCESS == err);

      embb_free(opencl_action);
      local_status = MTAPI_SUCCESS;
    }
  }

  mtapi_status_set(status, local_status);
}
예제 #2
0
static void CL_API_CALL opencl_task_complete(
  cl_event ev, cl_int status, void * data) {
  EMBB_UNUSED(ev);
  EMBB_UNUSED(status);

  cl_int err;
  EMBB_UNUSED_IN_RELEASE(err);
  embb_mtapi_opencl_task_t * opencl_task = (embb_mtapi_opencl_task_t*)data;

  if (embb_mtapi_node_is_initialized()) {
    embb_mtapi_node_t * node = embb_mtapi_node_get_instance();

    if (embb_mtapi_task_pool_is_handle_valid(
      node->task_pool, opencl_task->task)) {
      embb_mtapi_task_t * local_task =
        embb_mtapi_task_pool_get_storage_for_handle(
          node->task_pool, opencl_task->task);

      err = clWaitForEvents(1, &opencl_task->kernel_finish_event);
      assert(CL_SUCCESS == err);

      if (NULL != opencl_task->result_buffer) {
        err = clReleaseMemObject(opencl_task->result_buffer);
        assert(CL_SUCCESS == err);
      }
      if (NULL != opencl_task->arguments) {
        err = clReleaseMemObject(opencl_task->arguments);
        assert(CL_SUCCESS == err);
      }

      embb_mtapi_task_set_state(local_task, MTAPI_TASK_COMPLETED);
    }
  }
}
예제 #3
0
파일: core_set.c 프로젝트: danklmn/embb
void embb_core_set_init(embb_core_set_t* core_set, int initializer) {
  assert(core_set != NULL);
  assert(embb_core_count_available() < 64 &&
    "Core sets are only supported up to 64 processors!");

  /* Cache windows processor grouping information */
  if (processor_info.group_count == 0) {
    /* Set relation group */
    LOGICAL_PROCESSOR_RELATIONSHIP rel = (LOGICAL_PROCESSOR_RELATIONSHIP)4;
    /* Assume only one element of SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX is
       returned to the buffer. */
    SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer;
    /* The length is that of the buffer */
    DWORD length = sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX);
    BOOL status = GetLogicalProcessorInformationEx(rel, &buffer, &length);
    assert(status == TRUE);
    EMBB_UNUSED_IN_RELEASE(status);
    processor_info.group_count = buffer.Group.ActiveGroupCount;
    for (unsigned short i = 0; i < processor_info.group_count; i++) {
      processor_info.processor_counts[i] =
        (unsigned short)(buffer.Group.GroupInfo[i].ActiveProcessorCount);
    }
  }

  if (initializer == 0) {
    embb_bitset_clear_all(&core_set->rep);
  } else {
    embb_bitset_set_n(&core_set->rep, embb_core_count_available());
  }
}
예제 #4
0
void mtapi_opencl_plugin_finalize(
  MTAPI_OUT mtapi_status_t* status) {
  mtapi_status_t local_status = MTAPI_ERR_UNKNOWN;

  cl_int err;
  EMBB_UNUSED_IN_RELEASE(err);
  embb_mtapi_opencl_plugin_t * plugin = &embb_mtapi_opencl_plugin;

  /* finalization */
  err = clReleaseCommandQueue(plugin->command_queue);
  assert(CL_SUCCESS == err);
  err = clReleaseContext(plugin->context);
  assert(CL_SUCCESS == err);

  local_status = MTAPI_SUCCESS;
  mtapi_status_set(status, local_status);
}
예제 #5
0
int embb_condition_destroy(embb_condition_t* condition_var) {
  assert(condition_var != NULL);
  EMBB_UNUSED_IN_RELEASE(condition_var);
  return EMBB_SUCCESS;
}