-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use cases: initial commit of hybrid programming models
- Loading branch information
1 parent
788b5b0
commit f3a10a8
Showing
11 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <pmix.h> | ||
|
||
#include "hybrid-prog-model/declare_model_cb.c" | ||
#include "hybrid-prog-model/parallel_omp_cb.c" | ||
#include "hybrid-prog-model/parallel_mpi_cb.c" | ||
|
||
static int openmp_thread () { | ||
pmix_info_t *info; | ||
#include "hybrid-prog-model/omp_thread.c" | ||
} | ||
|
||
static int mpi_thread () { | ||
pmix_info_t *info; | ||
#include "hybrid-prog-model/mpi_thread.c" | ||
} | ||
|
||
int main() { | ||
#include "hybrid-prog-model/declare_model.c" | ||
#include "hybrid-prog-model/register_declare_model_cb.c" | ||
|
||
if () { | ||
openmp_thread(); | ||
} else { | ||
mpi_thread(); | ||
} | ||
|
||
#include "hybrid-prog-model/notify_event.c" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// in `main` function | ||
pmix_proc_t myproc; | ||
pmix_info_t *info; | ||
|
||
PMIX_INFO_CREATE(info, 4); | ||
PMIX_INFO_LOAD(&info[0], PMIX_PROGRAMMING_MODEL, | ||
"MPI", PMIX_STRING); | ||
PMIX_INFO_LOAD(&info[1], PMIX_MODEL_LIBRARY_NAME, | ||
"FooMPI", PMIX_STRING); | ||
PMIX_INFO_LOAD(&info[2], PMIX_MODEL_LIBRARY_VERSION, | ||
"1.0.0", PMIX_STRING); | ||
PMIX_INFO_LOAD(&info[3], PMIX_THREADING_MODEL, | ||
"pthread", PMIX_STRING); | ||
pmix_status_t rc = PMIx_Init(&myproc, info, 4); | ||
PMIX_INFO_FREE(info, 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
static void | ||
model_declared_cb(size_t evhdlr_registration_id, pmix_status_t status, | ||
const pmix_proc_t *source, pmix_info_t info[], | ||
size_t ninfo, pmix_info_t results[], size_t nresults, | ||
pmix_event_notification_cbfunc_fn_t cbfunc, | ||
void *cbdata) | ||
{ | ||
for (n = 0; n < ninfo; n++) { | ||
if (PMIX_CHECK_KEY(info[n], PMIX_PROGRAMMING_MODEL) && | ||
strcmp(info[n].value.data.string, "MPI") == 0) { | ||
/* ignore our own declaration */ | ||
break; | ||
} else { | ||
/* actions to perform when another model registers */ | ||
} | ||
} | ||
if (NULL != cbfunc) { | ||
/* tell the event handler that we are only a partial step */ | ||
cbfunc(PMIX_EVENT_PARTIAL_ACTION_TAKEN, NULL, 0, NULL, NULL, | ||
cbdata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pmix_status_t code = PMIX_OPENMP_PARALLEL_ENTERED; | ||
PMIX_INFO_CREATE(info, 2); | ||
PMIX_INFO_LOAD(&info[0], PMIX_EVENT_HDLR_NAME, | ||
"MPI-Thread", PMIX_STRING); | ||
PMIX_INFO_LOAD(&info[1], PMIX_EVENT_HDLR_AFTER, | ||
"OpenMP-Master", PMIX_STRING); | ||
rc = PMIx_Register_event_handler(&code, 1, info, 1, | ||
parallel_region_entered_cb, | ||
NULL, NULL); | ||
PMIX_INFO_FREE(info, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// in `main` function | ||
PMIx_Notify_event(PMIX_OPENMP_PARALLEL_ENTERED, &myproc, myproc.nspace, | ||
NULL, 0, NULL, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pmix_status_t code = PMIX_OPENMP_PARALLEL_ENTERED; | ||
PMIX_INFO_CREATE(info, 2); | ||
PMIX_INFO_LOAD(&info[0], PMIX_EVENT_HDLR_NAME, | ||
"OpenMP-Master", PMIX_STRING); | ||
PMIX_INFO_LOAD(&info[1], PMIX_EVENT_HDLR_FIRST, | ||
true, PMIX_BOOL); | ||
rc = PMIx_Register_event_handler(&code, 1, info, 1, | ||
parallel_region_entered_cb, | ||
NULL, NULL); | ||
PMIX_INFO_FREE(info, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
static void | ||
parallel_region_MPI_cb(size_t evhdlr_registration_id, | ||
pmix_status_t status, | ||
const pmix_proc_t *source, | ||
pmix_info_t info[], size_t ninfo, | ||
pmix_info_t results[], size_t nresults, | ||
pmix_event_notification_cbfunc_fn_t cbfunc, | ||
void *cbdata) | ||
{ | ||
/* do what we need MPI to do on entering a parallel region */ | ||
if (NULL != cbfunc) { | ||
/* tell the event handler that we are only a partial step */ | ||
cbfunc(PMIX_EVENT_ACTION_COMPLETE, NULL, 0, NULL, NULL, | ||
cbdata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
static void | ||
parallel_region_OMP_cb(size_t evhdlr_registration_id, | ||
pmix_status_t status, | ||
const pmix_proc_t *source, | ||
pmix_info_t info[], size_t ninfo, | ||
pmix_info_t results[], size_t nresults, | ||
pmix_event_notification_cbfunc_fn_t cbfunc, | ||
void *cbdata) | ||
{ | ||
/* do what we need OpenMP to do on entering a parallel region */ | ||
if (NULL != cbfunc) { | ||
/* tell the event handler that we are only a partial step */ | ||
cbfunc(PMIX_EVENT_PARTIAL_ACTION_TAKEN, NULL, 0, NULL, NULL, | ||
cbdata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// in `main` function | ||
pmix_status_t code = PMIX_MODEL_DECLARED; | ||
rc = PMIx_Register_event_handler(&code, 1, NULL, 0, model_declared_cb, | ||
NULL, NULL); |