31#include "control/common.h"
32#include "chameleon/runtime.h"
115 CHAM_context_t *chamctxt;
119 if (chamctxt == NULL) {
121 return CHAMELEON_ERR_OUT_OF_RESOURCES;
124#if defined(CHAMELEON_USE_MPI)
125# if defined(CHAMELEON_SIMULATION)
127 chamctxt->mpi_outer_init = 1;
130 int flag = 0, provided = 0;
131 MPI_Initialized( &flag );
132 chamctxt->mpi_outer_init = flag;
138 const int required = MPI_THREAD_MULTIPLE;
139 if ( MPI_Init_thread( NULL, NULL, required, &provided ) != MPI_SUCCESS) {
142 if ( provided < required ) {
144 "MPI_Init_thread() was not able to provide the requested thread support (MPI_THREAD_MULTIPLE),\n"
145 "this may be an issue if the level provided is not enough for the underlying runtime system." );
152#if !defined(CHAMELEON_USE_CUDA) && !defined(CHAMELEON_USE_HIP)
154 chameleon_warning(
"CHAMELEON_Init",
"CHAMELEON_USE_CUDA or CHAMELEON_USE_HIP are not defined, ngpus is forced to 0");
159 chamctxt->ncudas = ngpus;
160 chamctxt->comm = comm;
161 return RUNTIME_init( chamctxt, ncpus, ngpus, nthreads_per_worker );
178 if (chamctxt == NULL) {
180 return CHAMELEON_ERR_NOT_INITIALIZED;
184 RUNTIME_flush( chamctxt );
187# if !defined(CHAMELEON_SIMULATION)
188 RUNTIME_barrier(chamctxt);
192 RUNTIME_finalize( chamctxt );
194#if defined(CHAMELEON_USE_MPI)
196 if ( !chamctxt->mpi_outer_init ) {
202 return CHAMELEON_SUCCESS;
218 if ( chamctxt == NULL ) {
240 if (chamctxt == NULL) {
242 return CHAMELEON_ERR_NOT_INITIALIZED;
244 if ( chamctxt->runtime_paused ) {
246 return CHAMELEON_SUCCESS;
248 chamctxt->runtime_paused = CHAMELEON_TRUE;
249 RUNTIME_pause(chamctxt);
250 return CHAMELEON_SUCCESS;
268 if (chamctxt == NULL) {
270 return CHAMELEON_ERR_NOT_INITIALIZED;
272 if ( !chamctxt->runtime_paused ) {
274 return CHAMELEON_SUCCESS;
276 chamctxt->runtime_paused = CHAMELEON_FALSE;
277 RUNTIME_resume(chamctxt);
278 return CHAMELEON_SUCCESS;
295 if (chamctxt == NULL) {
297 return CHAMELEON_ERR_NOT_INITIALIZED;
299 RUNTIME_barrier( chamctxt );
300 return CHAMELEON_SUCCESS;
317 if (chamctxt == NULL) {
319 return CHAMELEON_ERR_NOT_INITIALIZED;
321 RUNTIME_barrier( chamctxt );
322 return CHAMELEON_SUCCESS;
340 if (chamctxt == NULL) {
345 return RUNTIME_comm_size( chamctxt );
363 if (chamctxt == NULL) {
368 return RUNTIME_comm_rank( chamctxt );
386 if (chamctxt == NULL) {
387 chameleon_error(
"CHAMELEON_GetThreadNbr",
"CHAMELEON not initialized");
391 return RUNTIME_thread_size( chamctxt );
void chameleon_error(const char *func_name, const char *msg_text)
void chameleon_warning(const char *func_name, const char *msg_text)
void chameleon_fatal_error(const char *func_name, const char *msg_text)
CHAM_context_t * chameleon_context_self()
CHAM_context_t * chameleon_context_create()
int chameleon_context_destroy()
int CHAMELEON_Resume(void)
int CHAMELEON_Comm_rank()
int __chameleon_init(int cores, int gpus)
Initialize CHAMELEON with number of cpus and gpus (using MPI_COMM_WORLD).
int CHAMELEON_Comm_size()
int CHAMELEON_Distributed_stop(void)
int __chameleon_initparcomm(int ncpus, int ngpus, int nthreads_per_worker, MPI_Comm comm)
Initialize CHAMELEON with number of cpus and gpus and threads per worker and using a given MPI commun...
int CHAMELEON_GetThreadNbr()
int __chameleon_initpar(int ncpus, int ngpus, int nthreads_per_worker)
Initialize CHAMELEON with number of cpus and gpus and threads per worker (using MPI_COMM_WORLD).
int CHAMELEON_Distributed_start(void)
int __chameleon_finalize(void)
Finalize CHAMELEON.
int CHAMELEON_Pause(void)
int CHAMELEON_Initialized(void)
Check if the CHAMELEON library is initialized or not.