This source file includes following definitions.
- main
1
2 #include <stdio.h>
3 #include <pmix.h>
4 #include <assert.h>
5
6 int main(int argc, char **argv)
7 {
8 pmix_proc_t myproc;
9 pmix_status_t rc;
10
11 int rank;
12 rc = PMIx_Init(&myproc, NULL, 0);
13 assert(PMIX_SUCCESS == rc);
14
15 {
16 pmix_value_t *value;
17 rc = PMIx_Get(&myproc, PMIX_RANK, NULL, 0, &value);
18 assert(PMIX_SUCCESS == rc);
19 printf("%d\n", value->type);
20 assert(value->type == PMIX_INT);
21 rank = value->data.uint32;
22 PMIX_VALUE_RELEASE(value);
23 }
24
25 if (rank == 0 ) {
26 pmix_info_t *info;
27 PMIX_INFO_CREATE(info, 1);
28 snprintf(info[0].key, PMIX_MAX_KEYLEN, "magic-found");
29 info[0].value.type = PMIX_STRING;
30 info[0].value.data.string = "yes";
31 rc = PMIx_Publish(info, 1);
32 assert(PMIX_SUCCESS == rc);
33 }
34
35 printf("I am rank %d\n", rank);
36
37 {
38 bool flag;
39 pmix_info_t *info;
40 PMIX_INFO_CREATE(info, 1);
41 flag = true;
42 PMIX_INFO_LOAD(info, PMIX_COLLECT_DATA, &flag, PMIX_BOOL);
43 rc = PMIx_Fence(&myproc, 1, info, 1);
44 assert(PMIX_SUCCESS == rc);
45 PMIX_INFO_FREE(info, 1);
46 }
47
48 if (rank == 1) {
49 int i;
50 pmix_pdata_t *pdata;
51 PMIX_PDATA_CREATE(pdata, 2);
52 snprintf(pdata[0].key, PMIX_MAX_KEYLEN, "magic-found");
53 snprintf(pdata[1].key, PMIX_MAX_KEYLEN, "magic-not-found");
54 rc = PMIx_Lookup(&pdata[0], 2, NULL, 0);
55 assert((PMIX_SUCCESS == rc) || (PMIX_ERR_NOT_FOUND == rc));
56 for ( i = 0 ; i < 2 ; i++ )
57 if (pdata[i].value.type == PMIX_STRING)
58 printf("Found[%d] %d %s\n", i, pdata[i].value.type, pdata[i].value.data.string);
59 else
60 printf("Found[%d] %d\n", i, pdata[i].value.type);
61 PMIX_PDATA_FREE(pdata, 1);
62 }
63
64 rc = PMIx_Finalize(NULL, 0);
65 assert(PMIX_SUCCESS == rc);
66
67 }