1/* 2 * Copyright (c) 2014 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, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef LIB_XOMP_MASTER_H_ 11#define LIB_XOMP_MASTER_H_ 12 13typedef enum xomp_master_copy { 14 XOMP_MASTER_COPY_INVALID, 15 XOMP_MASTER_COPY_UPDATE, 16 XOMP_MASTER_COPY_WRITE_BACK 17} xomp_master_copy_t; 18 19#define XOMP_MASTER_COPY_NODE_ALL 0xFFFF 20 21#define XOMP_MASTER_BENCH_SPAWN (1 << 0) 22#define XOMP_MASTER_BENCH_MEM_ADD (1 << 1) 23#define XOMP_MASTER_BENCH_DO_WORK (1 << 2) 24 25/** 26 * \brief initializes the Xeon Phi openMP library 27 * 28 * \param args struct containing the master initialization values 29 * 30 * \returns SYS_ERR_OK on success 31 * errval on failure 32 */ 33errval_t xomp_master_init(struct xomp_args *args); 34 35/** 36 * \brief Spawns the worker threads on the Xeon Phi 37 * 38 * \param nworkers Number of total workers this includes the Master 39 * 40 * \returns SYS_ERR_OK on success 41 * errval on failure 42 */ 43errval_t xomp_master_spawn_workers(uint32_t nworkers); 44 45/** 46 * \brief Adds a memory region to be used for work 47 * 48 * \param frame Frame to be shared 49 * \param info information about the frame i.e. virtual address to map 50 * \oaram type Type of the frame 51 * 52 * \returns SYS_ERR_OK on success 53 * errval on error 54 */ 55errval_t xomp_master_add_memory(struct capref frame, 56 uint64_t info, 57 xomp_frame_type_t type); 58 59/** 60 * \brief tells the gateway domains to update their local replicas 61 * 62 * \param frame capability of the shared frame 63 * \param offset offset into the capability to copy 64 * \param length number of bytes to copy 65 * \param node which node to send the copy request to 66 * \param direction UPDATE or WRITE BACK 67 * 68 * \return SYS_ERR_OK on sucess, 69 * errval on failure 70 */ 71errval_t xomp_master_copy_memory(struct capref frame, 72 size_t offset, 73 size_t length, 74 uint16_t node, 75 xomp_master_copy_t direction); 76 77/** 78 * \brief executes some work on each worker domains 79 * 80 * \param task information about the task 81 * 82 * \returns SYS_ERR_OK on success 83 * errval on error 84 */ 85errval_t xomp_master_do_work(struct xomp_task *task); 86 87/** 88 * \brief builds the argument path based on the own binary name 89 * 90 * \param local pointer where to store the local path 91 * \param remote pointer where to store the remote path 92 * 93 * \returns SYS_ERR_OK on success 94 */ 95errval_t xomp_master_build_path(char **local, char **remote); 96 97 98#if XOMP_BENCH_ENABLED 99/** 100 * \brief enables basic benchmarking facilities 101 * 102 * \param runs the number of runs of the experiment 103 * \param flags flags which benchmarks to enable 104 * 105 * \returns SYS_ERR_OK on success 106 */ 107errval_t xomp_master_bench_enable(size_t runs, 108 size_t nthreads, 109 uint8_t flags); 110 111/** 112 * \brief prints the results of the enabled benchmarks 113 */ 114void xomp_master_bench_print_results(void); 115 116#else 117#include <barrelfish/debug.h> 118 119static inline errval_t xomp_master_bench_enable(size_t runs, 120 size_t nthreads, 121 uint8_t flags) 122{ 123 USER_PANIC("XOMP BENCHMARK NOT ENABLED"); 124 return -1; 125} 126 127static inline void xomp_master_bench_print_results(void) 128{ 129 USER_PANIC("XOMP BENCHMARK NOT ENABLED"); 130} 131#endif 132 133#endif // LIB_XOMP_MASTER_H_ 134