File: simptool.c

package info (click to toggle)
openmpi 5.0.8-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,692 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (114 lines) | stat: -rw-r--r-- 4,760 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2011 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2006-2013 Los Alamos National Security, LLC.
 *                         All rights reserved.
 * Copyright (c) 2009-2012 Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2011      Oak Ridge National Labs.  All rights reserved.
 * Copyright (c) 2013-2020 Intel, Inc.  All rights reserved.
 * Copyright (c) 2015      Mellanox Technologies, Inc.  All rights reserved.
 * Copyright (c) 2021-2023 Nanook Consulting.  All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 *
 */

#include "src/include/pmix_config.h"
#include "include/pmix_tool.h"

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

#include "src/class/pmix_object.h"
#include "src/include/pmix_globals.h"
#include "src/util/pmix_argv.h"
#include "src/util/pmix_output.h"
#include "src/util/pmix_printf.h"

static pmix_proc_t myproc;

int main(int argc, char **argv)
{
    pmix_status_t rc;
    pmix_query_t *query;
    size_t nq;
    pmix_info_t *results = NULL;
    size_t nresults = 0;
    PMIX_HIDE_UNUSED_PARAMS(argc, argv);

    /* init us */
    if (PMIX_SUCCESS != (rc = PMIx_tool_init(&myproc, NULL, 0))) {
        fprintf(stderr, "PMIx_tool_init failed: %d\n", rc);
        exit(rc);
    }
    pmix_output(0, "Tool ns %s rank %d: Running", myproc.nspace, myproc.rank);

    /* query something */
    nq = 2;
    PMIX_QUERY_CREATE(query, nq);
    PMIx_Argv_append_nosize(&query[0].keys, "foobar");
    PMIx_Argv_append_nosize(&query[1].keys, "spastic");
    PMIx_Argv_append_nosize(&query[1].keys, PMIX_SERVER_URI);
    if (PMIX_SUCCESS != (rc = PMIx_Query_info(query, nq, &results, &nresults))) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info failed: %d", myproc.nspace,
                    myproc.rank, rc);
        goto done;
    }
    if (2 != nresults || NULL == results) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info returned incorrect results: %d",
                    myproc.nspace, myproc.rank, (int) nresults);
        goto done;
    }
    if (0 != strncmp(results[0].key, "foobar", PMIX_MAX_KEYLEN)) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info[0] key wrong: %s vs foobar",
                    myproc.nspace, myproc.rank, results[0].key);
    }
    if (0 != strncmp(results[1].key, "spastic", PMIX_MAX_KEYLEN)) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info[1] key wrong: %s vs spastic",
                    myproc.nspace, myproc.rank, results[1].key);
    }
    if (PMIX_STRING != results[0].value.type) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[0] wrong type: %d vs %d",
                    myproc.nspace, myproc.rank, results[0].value.type, PMIX_STRING);
    }
    if (PMIX_STRING != results[1].value.type) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[1] wrong type: %d vs %d",
                    myproc.nspace, myproc.rank, results[1].value.type, PMIX_STRING);
    }
    if (0 != strcmp(results[0].value.data.string, "0")) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[0] wrong value: %s vs 0",
                    myproc.nspace, myproc.rank, results[1].value.data.string);
    }
    if (0 != strcmp(results[1].value.data.string, "1")) {
        pmix_output(0, "Client ns %s rank %d: PMIx_Query_info key[1] wrong value: %s vs 1",
                    myproc.nspace, myproc.rank, results[1].value.data.string);
    }
    pmix_output(0, "Client received result %s:%s", results[0].key, results[0].value.data.string);
    pmix_output(0, "Client received result %s:%s", results[1].key, results[1].value.data.string);

done:
    /* finalize us */
    pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
    if (PMIX_SUCCESS != (rc = PMIx_tool_finalize())) {
        fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %d\n", myproc.nspace,
                myproc.rank, rc);
    } else {
        fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n",
                myproc.nspace, myproc.rank);
    }
    fflush(stderr);
    return (rc);
}