Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 769518d2 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Add the possibility to enter Chameleon with an existing starpu (Need to be...

Add the possibility to enter Chameleon with an existing starpu (Need to be cleanup on the starpu_initialized function)
parent b68718b7
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@
#include <stdlib.h>
#include "runtime/starpu/include/morse_starpu.h"
int _starpu_is_initialized(void);
/*******************************************************************************
* Create new context
**/
......@@ -34,10 +36,16 @@ void RUNTIME_context_create( MORSE_context_t *morse )
starpu_conf_t *conf;
morse->scheduler = CHAMELEON_SCHED_STARPU;
morse->schedopt = (void*) malloc (sizeof(struct starpu_conf));
conf = morse->schedopt;
starpu_conf_init( conf );
if (! _starpu_is_initialized() ) {
morse->schedopt = (void*) malloc (sizeof(struct starpu_conf));
conf = morse->schedopt;
starpu_conf_init( conf );
}
else {
morse->schedopt = NULL;
}
return;
}
......@@ -48,7 +56,10 @@ void RUNTIME_context_create( MORSE_context_t *morse )
void RUNTIME_context_destroy( MORSE_context_t *morse )
{
free(morse->schedopt);
/* StarPU was already initialized by an external library */
if (morse->schedopt) {
free(morse->schedopt);
}
return;
}
......
......@@ -44,6 +44,11 @@ int RUNTIME_init_scheduler( MORSE_context_t *morse, int ncpus, int ncudas, int n
starpu_conf_t *conf = (starpu_conf_t*)(morse->schedopt);
int hres = -1;
/* StarPU was already initialized by an external library */
if (conf == NULL) {
return 0;
}
conf->ncpus = ncpus;
conf->ncuda = ncudas;
conf->nopencl = 0;
......@@ -124,6 +129,12 @@ int RUNTIME_init_scheduler( MORSE_context_t *morse, int ncpus, int ncudas, int n
void RUNTIME_finalize_scheduler( MORSE_context_t *morse )
{
(void)morse;
/* StarPU was already initialized by an external library */
if (morse->schedopt == NULL) {
return 0;
}
#if defined(CHAMELEON_USE_MPI)
starpu_mpi_shutdown();
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment