PFUNC 1.0
Defines | Variables
lib/pfunc_c.cpp File Reference
#include <pfunc/config.h>
#include <pfunc/pfunc.h>
#include <pfunc/exception.hpp>

Defines

#define PFUNC_LIBRARY_CODE
#define PFUNC_GEN_ATTR_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_ATTR_SET_DEFS(sched)
#define PFUNC_GEN_ATTR_GET_DEFS(sched)
#define PFUNC_GEN_ATTR_DEFS(sched)
#define PFUNC_GEN_GROUP_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_GROUP_SET_DEFS(sched)
#define PFUNC_GEN_GROUP_GET_DEFS(sched)
#define PFUNC_GEN_GROUP_DEFS(sched)
#define PFUNC_GEN_TASK_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_TASK_DEFS(sched)   PFUNC_GEN_TASK_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_TASKMGR_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_TASKMGR_SET_AND_GET_MAX_ATTEMPTS_DEFS(sched)
#define PFUNC_GEN_TASKMGR_DEFS(sched)
#define PFUNC_GEN_TESTS_AND_WAITS_DEFS(sched)
#define PFUNC_GEN_RUN_DEFS(sched)
#define PFUNC_GEN_RANK_AND_SIZE_DEFS(sched)
#define PFUNC_GEN_WORK_TYPES_DEFS(sched)
#define PFUNC_GEN_GLOBAL_TASKMGR_INIT_CLEAR_DEFS(sched)
#define PFUNC_GEN_TASKMGR_GLOBAL_SET_AND_GET_MAX_ATTEMPTS_DEFS(sched)
#define PFUNC_GEN_GLOBAL_TASKMGR_DEFS(sched)
#define PFUNC_GEN_GLOBAL_TESTS_AND_WAITS_DEFS(sched)
#define PFUNC_GEN_GLOBAL_RUN_DEFS(sched)
#define PFUNC_GEN_GLOBAL_RANK_AND_SIZE_DEFS(sched)
#define PFUNC_GEN_ALL_TYPES_DEFS(sched)

Variables

pfunc_cilk_taskmgr_t pfunc_cilk_global_tmanager = NULL
pfunc_fifo_taskmgr_t pfunc_fifo_global_tmanager = NULL
pfunc_lifo_taskmgr_t pfunc_lifo_global_tmanager = NULL
pfunc_prio_taskmgr_t pfunc_prio_global_tmanager = NULL

Define Documentation

#define PFUNC_GEN_ALL_TYPES_DEFS (   sched)
#define PFUNC_GEN_ATTR_DEFS (   sched)
#define PFUNC_GEN_ATTR_GET_DEFS (   sched)
#define PFUNC_GEN_ATTR_INITCLEAR_DEFS (   sched)
Value:
int pfunc_##sched##_attr_init (pfunc_##sched##_attr_t* attr) { \
  PFUNC_START_TRY_BLOCK() \
  *attr = reinterpret_cast<pfunc_##sched##_attr_t> \
            (new (std::nothrow) pfunc::detail::pfunc_##sched##_attr_t); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
\
int pfunc_##sched##_attr_clear (pfunc_##sched##_attr_t* attr) { \
  PFUNC_START_TRY_BLOCK() \
  delete reinterpret_cast<pfunc::detail::pfunc_##sched##_attr_t*> (*attr); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
}
#define PFUNC_GEN_ATTR_SET_DEFS (   sched)
#define PFUNC_GEN_GLOBAL_RANK_AND_SIZE_DEFS (   sched)
Value:
int pfunc_##sched##_thread_id_gbl (unsigned int* id) { \
  return pfunc_##sched##_thread_id (pfunc_##sched##_global_tmanager, id); \
} \
\
int pfunc_##sched##_group_rank_gbl (unsigned int* rank) { \
  return pfunc_##sched##_group_rank (pfunc_##sched##_global_tmanager, rank); \
} \
\
int pfunc_##sched##_group_size_gbl (unsigned int* size) { \
  return pfunc_##sched##_group_size (pfunc_##sched##_global_tmanager, size); \
} \
\
int pfunc_##sched##_barrier_gbl ( ) { \
  return pfunc_##sched##_barrier (pfunc_##sched##_global_tmanager); \
}
#define PFUNC_GEN_GLOBAL_RUN_DEFS (   sched)
Value:
int pfunc_##sched##_spawn_c_gbl (pfunc_##sched##_task_t task, \
                                 pfunc_##sched##_attr_t attr, \
                                 pfunc_##sched##_group_t group, \
                                 pfunc_c_work_func_t work, \
                                 void* arg) { \
  return pfunc_##sched##_spawn_c (pfunc_##sched##_global_tmanager, \
                                task, \
                                attr, \
                                group, \
                                work, \
                                arg); \
} \
\
int pfunc_##sched##_spawn_cxx_gbl (pfunc_##sched##_task_t task, \
                                   pfunc_##sched##_attr_t attr, \
                                   pfunc_##sched##_group_t group, \
                                   pfunc_##sched##_work_t work) { \
  return pfunc_##sched##_spawn_cxx (pfunc_##sched##_global_tmanager, \
                                    task, \
                                    attr, \
                                    group, \
                                    work); \
} \
#define PFUNC_GEN_GLOBAL_TASKMGR_DEFS (   sched)
#define PFUNC_GEN_GLOBAL_TASKMGR_INIT_CLEAR_DEFS (   sched)
Value:
int pfunc_##sched##_init (pfunc_##sched##_taskmgr_t* local_tmanager) { \
  int return_value;  \
  if (NULL == local_tmanager || NULL == *local_tmanager) { \
    return_value = PFUNC_INVALID_ARGUMENTS; \
  } else { \
    pfunc_##sched##_global_tmanager = *local_tmanager; \
    return_value = PFUNC_SUCCESS; \
  } \
  return return_value; \
} \
\
int pfunc_##sched##_clear () { \
  int return_value; \
  if (NULL == pfunc_##sched##_global_tmanager) { \
    return_value = PFUNC_INVALID_ARGUMENTS; \
  } else { \
    pfunc_##sched##_global_tmanager = NULL; \
    return_value = PFUNC_SUCCESS; \
  } \
  return return_value; \
}
#define PFUNC_GEN_GLOBAL_TESTS_AND_WAITS_DEFS (   sched)
#define PFUNC_GEN_GROUP_DEFS (   sched)
#define PFUNC_GEN_GROUP_GET_DEFS (   sched)
#define PFUNC_GEN_GROUP_INITCLEAR_DEFS (   sched)
Value:
int pfunc_##sched##_group_init (pfunc_##sched##_group_t* group) { \
  PFUNC_START_TRY_BLOCK() \
  *group = reinterpret_cast<pfunc_##sched##_group_t> \
            (new (std::nothrow) pfunc::detail::pfunc_##sched##_group_t); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
\
int pfunc_##sched##_group_clear (pfunc_##sched##_group_t* group) { \
  PFUNC_START_TRY_BLOCK() \
  delete reinterpret_cast<pfunc::detail::pfunc_##sched##_group_t*> (*group); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
}
#define PFUNC_GEN_GROUP_SET_DEFS (   sched)
#define PFUNC_GEN_RANK_AND_SIZE_DEFS (   sched)

functions for getting rank and size

#define PFUNC_GEN_RUN_DEFS (   sched)

functions for spawn

#define PFUNC_GEN_TASK_DEFS (   sched)    PFUNC_GEN_TASK_INITCLEAR_DEFS(sched)
#define PFUNC_GEN_TASK_INITCLEAR_DEFS (   sched)
Value:
int pfunc_##sched##_task_init (pfunc_##sched##_task_t* task) { \
  PFUNC_START_TRY_BLOCK() \
  *task = reinterpret_cast<pfunc_##sched##_task_t> \
    (new (std::nothrow) pfunc::detail::pfunc_##sched##_task_t ()); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
\
int pfunc_##sched##_task_clear (pfunc_##sched##_task_t* task) { \
  PFUNC_START_TRY_BLOCK() \
  delete reinterpret_cast<pfunc::detail::pfunc_##sched##_task_t*> (*task); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
}
#define PFUNC_GEN_TASKMGR_DEFS (   sched)
#define PFUNC_GEN_TASKMGR_GLOBAL_SET_AND_GET_MAX_ATTEMPTS_DEFS (   sched)
Value:
int pfunc_##sched##_taskmgr_max_attempts_set_gbl \
                         (const unsigned int max_attempts) { \
  return pfunc_##sched##_taskmgr_max_attempts_set \
                                          (pfunc_##sched##_global_tmanager, \
                                           max_attempts); \
} \
\
int pfunc_##sched##_taskmgr_max_attempts_get_gbl \
                         (unsigned int* max_attempts) { \
  return pfunc_##sched##_taskmgr_max_attempts_get \
                                          (pfunc_##sched##_global_tmanager, \
                                           max_attempts); \
} \
#define PFUNC_GEN_TASKMGR_INITCLEAR_DEFS (   sched)
Value:
int pfunc_##sched##_taskmgr_init (pfunc_##sched##_taskmgr_t* taskmgr, \
                              const unsigned int num_queues, \
                              const unsigned int* num_threads_per_queue, \
                              const unsigned int** thread_affinities) { \
  PFUNC_START_TRY_BLOCK() \
  *taskmgr = reinterpret_cast<pfunc_##sched##_taskmgr_t> \
    (new (std::nothrow) pfunc::detail::pfunc_##sched##_taskmgr_t (num_queues, \
                                                      num_threads_per_queue, \
                                                      thread_affinities)); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
\
int pfunc_##sched##_taskmgr_clear (pfunc_##sched##_taskmgr_t* taskmgr) { \
  PFUNC_START_TRY_BLOCK() \
  delete reinterpret_cast<pfunc::detail::pfunc_##sched##_taskmgr_t*> (*taskmgr); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
}
#define PFUNC_GEN_TASKMGR_SET_AND_GET_MAX_ATTEMPTS_DEFS (   sched)
Value:
int pfunc_##sched##_taskmgr_max_attempts_set \
                        (pfunc_##sched##_taskmgr_t taskmgr, \
                         const unsigned int max_attempts) { \
  PFUNC_START_TRY_BLOCK() \
  pfunc::detail::pfunc_##sched##_taskmgr_t& cpp_taskmgr = \
      *(reinterpret_cast<pfunc::detail::pfunc_##sched##_taskmgr_t*>(taskmgr)); \
  cpp_taskmgr.set_max_attempts (max_attempts); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
\
int pfunc_##sched##_taskmgr_max_attempts_get \
                        (pfunc_##sched##_taskmgr_t taskmgr, \
                         unsigned int* max_attempts) { \
  PFUNC_START_TRY_BLOCK() \
  pfunc::detail::pfunc_##sched##_taskmgr_t& cpp_taskmgr = \
      *(reinterpret_cast<pfunc::detail::pfunc_##sched##_taskmgr_t*>(taskmgr)); \
  *max_attempts = cpp_taskmgr.get_max_attempts (); \
  return PFUNC_SUCCESS; \
  PFUNC_END_TRY_BLOCK() \
  PFUNC_C_CATCH_AND_RETURN_EXCEPTION_CODE() \
} \
#define PFUNC_GEN_TESTS_AND_WAITS_DEFS (   sched)

functions for waits and tests

#define PFUNC_GEN_WORK_TYPES_DEFS (   sched)
#define PFUNC_LIBRARY_CODE

Variable Documentation

pfunc_cilk_taskmgr_t pfunc_cilk_global_tmanager = NULL

definition of the cilk global taskmgr object

pfunc_fifo_taskmgr_t pfunc_fifo_global_tmanager = NULL

definition of the fifo global taskmgr object

pfunc_lifo_taskmgr_t pfunc_lifo_global_tmanager = NULL

definition of the lifo global taskmgr object

pfunc_prio_taskmgr_t pfunc_prio_global_tmanager = NULL

definition of the prio global taskmgr object