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#include <barrelfish/barrelfish.h>
10#include <omp.h>
11#include <xomp/xomp.h>
12
13#include <flounder/flounder_support_ump.h>
14
15#include "xomptest.h"
16
17void do_process(uint32_t *src,
18                uint32_t *dst)
19{
20
21    if (src == NULL || dst == 0) {
22        return;
23    }
24#pragma omp parallel for
25    for (int j = 0; j < IT; j++) {
26        for (int i = 0; i < WORK_MAX; i += IT) {
27            dst[i + j] = src[i + j];
28        }
29    }
30}
31
32int main(int argc,
33         char *argv[])
34{
35    errval_t err;
36
37    xomp_wid_t wid;
38    err = xomp_worker_parse_cmdline(argc, argv, &wid);
39    switch (err_no(err)) {
40        case SYS_ERR_OK:
41            debug_printf("XOMP Test started. (WORKER) %u\n", argc);
42            err = xomp_worker_init(wid);
43            if (err_is_fail(err)) {
44                USER_PANIC_ERR(err, "could not initialize the worker\n");
45            }
46            break;
47        case XOMP_ERR_BAD_INVOCATION:
48            debug_printf("XOMP Test started. (MASTER) %u\n", argc);
49            err = start_master(argc, argv);
50            if (err_is_fail(err)) {
51                USER_PANIC_ERR(err, "start_master");
52            }
53            break;
54        default:
55            break;
56    }
57
58    if (err_is_fail(err)) {
59        USER_PANIC_ERR(err, "during initialization");
60    }
61
62    while (1) {
63        messages_wait_and_handle_next();
64    }
65
66    return 0;
67}
68
69