1/**
2 * \file
3 * \brief
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include "ump_bench.h"
16
17#define MAX_COUNT 100
18static struct timestamps *timestamps;
19
20void experiment(coreid_t idx)
21{
22    timestamps = malloc(sizeof(struct timestamps) * MAX_COUNT);
23    assert(timestamps != NULL);
24
25    struct bench_ump_binding *bu = (struct bench_ump_binding*)array[idx];
26    struct flounder_ump_state *fus = &bu->ump_state;
27    struct ump_chan *chan = &fus->chan;
28
29    struct ump_chan_state *send = &chan->send_chan;
30    struct ump_chan_state *recv = &chan->endpoint.chan;
31
32    printf("Running receive between core %d and core %d\n",
33           my_core_id, idx);
34
35    volatile struct ump_message *msg;
36    struct ump_control ctrl;
37
38    for (int i = 0; i < MAX_COUNT; i++) {
39        while (!(msg = ump_impl_get_next(send, &ctrl)));
40        msg->header.control = ctrl;
41        while(true) {
42            timestamps[i].time0 = bench_tsc();
43            if ((msg = ump_impl_recv(recv))) {
44                ump_impl_free_message(msg);
45                timestamps[i].time1 = bench_tsc();
46                break;
47            }
48        }
49    }
50
51    /* Print results */
52    for (int i = MAX_COUNT / 10; i < MAX_COUNT; i++) {
53        printf("page %d took %"PRIuCYCLES"\n", i,
54               timestamps[i].time1 - timestamps[i].time0
55               - bench_tscoverhead());
56    }
57
58}
59