1/** 2 * \file 3 * \brief no-op dummy for testing the benchmark framework 4 * 5 * Use this as a template if you want to write your own benchmark 6 */ 7 8/* 9 * Copyright (c) 2017, ETH Zurich. 10 * All rights reserved. 11 * 12 * This file is distributed under the terms in the attached LICENSE file. 13 * If you do not find this file, copies can be found by writing to: 14 * ETH Zurich D-INFK, Universitaetstr 6, CH-8092 Zurich. Attn: Systems Group. 15 */ 16 17#include <barrelfish/barrelfish.h> 18#include <if/bench_distops_defs.h> 19 20#include "benchapi.h" 21 22//{{{1 debugging helpers 23static void debug_capref(const char *prefix, struct capref cap) 24{ 25 char buf[128]; 26 debug_print_capref(buf, 128, cap); 27 printf("%s capref = %s\n", prefix, buf); 28} 29 30//{{{1 Managment node: implement orchestration for benchmark 31 32//{{{2 Management node: state management 33 34struct global_state { 35 coreid_t *nodes; 36 int nodecount; 37 int nodes_seen; 38}; 39 40errval_t mgmt_init_benchmark(void **st, int nodecount) 41{ 42 *st = calloc(1, sizeof(struct global_state)); 43 if (!*st) { 44 return LIB_ERR_MALLOC_FAIL; 45 } 46 struct global_state *gs = *st; 47 gs->nodes = calloc(nodecount, sizeof(coreid_t)); 48 gs->nodecount = nodecount; 49 return SYS_ERR_OK; 50} 51 52void mgmt_register_node(void *st, coreid_t nodeid) 53{ 54 struct global_state *gs = st; 55 gs->nodes[gs->nodes_seen++] = nodeid; 56} 57 58struct mgmt_node_state { 59}; 60 61errval_t mgmt_init_node(void **st) 62{ 63 *st = malloc(sizeof(struct mgmt_node_state)); 64 if (!*st) { 65 return LIB_ERR_MALLOC_FAIL; 66 } 67 return SYS_ERR_OK; 68} 69 70//{{{2 Management node: benchmark impl 71void mgmt_run_benchmark(void *st) 72{ 73 printf("All clients sent hello! Benchmark would start.\n"); 74 printf("NOOP Benchmark test done!\n"); 75} 76 77void mgmt_cmd(uint32_t cmd, uint32_t arg, struct bench_distops_binding *b) 78{ 79 printf("mgmt node got command %d(arg = %d) over binding %p\n", cmd, arg, b); 80} 81 82void mgmt_cmd_caps(uint32_t cmd, uint32_t arg, struct capref cap1, 83 struct bench_distops_binding *b) 84{ 85 printf("mgmt node got caps + command %"PRIu32", arg=%d over binding %p:\n", 86 cmd, arg, b); 87 debug_capref("cap1:", cap1); 88} 89 90//{{{1 Node 91 92struct node_state { 93}; 94 95static coreid_t my_core_id = -1; 96 97void init_node(struct bench_distops_binding *b) 98{ 99 printf("%s: binding = %p\n", __FUNCTION__, b); 100 101 my_core_id = disp_get_core_id(); 102 103 // Allocate client state struct 104 b->st = malloc(sizeof(struct node_state)); 105 assert(b->st); 106 if (!b->st) { 107 USER_PANIC("state malloc() in client"); 108 } 109} 110 111void node_cmd(uint32_t cmd, uint32_t arg, struct bench_distops_binding *b) 112{ 113 printf("node %d got command %"PRIu32", arg=%d\n", my_core_id, cmd, arg); 114} 115 116void node_cmd_caps(uint32_t cmd, uint32_t arg, struct capref cap1, 117 struct bench_distops_binding *b) 118{ 119 printf("node %d got caps + command %"PRIu32", arg=%d:\n", my_core_id, cmd, arg); 120 debug_capref("cap1:", cap1); 121} 122