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 throughput 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    for (int i = 0; i < NUM_MSGS; i++) { /* Fill up the buffer */
38        while (!(msg = ump_impl_get_next(send, &ctrl)));
39        msg->header.control = ctrl;
40    }
41
42    cycles_t ts = bench_tsc();
43    for (int i = 0; i < MAX_COUNT; i++) { /* Sustained sending of msgs */
44        timestamps[i].time0 = ts;
45        while (!(msg = ump_impl_recv(recv)));
46        ump_impl_free_message(msg);
47        ts = timestamps[i].time1 = bench_tsc();
48        while (!(msg = ump_impl_get_next(send, &ctrl)));
49        msg->header.control = ctrl;
50    }
51
52    for (int i = 0; i < NUM_MSGS; i++) { /* Empty the buffer */
53        while (!(msg = ump_impl_recv(recv)));
54        ump_impl_free_message(msg);
55    }
56
57    /* Print results */
58    for (int i = 0; i < MAX_COUNT; i++) {
59        if (timestamps[i].time1 > timestamps[i].time0) {
60            printf("page %d took %"PRIuCYCLES"\n", i,
61                   timestamps[i].time1 - bench_tscoverhead() -
62                   timestamps[i].time0);
63        }
64    }
65}
66