1/*
2 * Copyright (c) 2007-12 ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10extern "C" {
11    #include <barrelfish_kpi/types.h>
12    #include <errors/errno.h>
13    #include <xomp/xomp.h>
14    #include "xomptest.h"
15}
16
17/// XXX: there seems to be some issues with this.., disabling this warning for now
18#pragma GCC diagnostic ignored "-Wshadow"
19#include <iostream>
20#pragma GCC diagnostic error "-Wshadow"
21
22
23#include <omp.h>
24
25using namespace std;
26
27void do_process(uint32_t *src,
28                uint32_t *dst)
29{
30    cout << "do_process C++ called " << endl;
31    if (src == NULL || dst == 0) {
32        return;
33    }
34#pragma omp parallel for
35    for (unsigned int j = 0; j < IT; j++) {
36        for (unsigned int i = 0; i < WORK_MAX; i += IT) {
37            dst[i + j] = src[i + j];
38        }
39    }
40}
41
42int main(int argc,
43         char *argv[])
44{
45    errval_t err;
46
47    xomp_wid_t wid;
48    err = xomp_worker_parse_cmdline(argc, argv, &wid);
49    switch (err_no(err)) {
50        case SYS_ERR_OK:
51            std::cout << "XOMP Test started. (WORKER) #args:" << argc << std::endl;
52            err = xomp_worker_init(wid);
53            if (err_is_fail(err)) {
54                std::cout <<  "could not initialize the worker: " << err_getstring(err) << std::endl;
55            }
56            break;
57        case XOMP_ERR_BAD_INVOCATION:
58            std::cout << "XOMP Test started. (MASTER) #args:" << argc << std::endl;
59            err = start_master(argc, argv);
60            if (err_is_fail(err)) {
61                std::cout <<  "could not start the master: " << err_getstring(err) << std::endl;
62            }
63            break;
64        default:
65            break;
66    }
67
68    if (err_is_fail(err)) {
69        std::cout <<  "error while initializing" << err_getstring(err) << std::endl;
70    }
71
72    handle_messages();
73
74    return 0;
75}
76
77