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_H_ 11#define LIB_XOMP_H_ 12 13/// arguments passed to worker domains 14#define XOMP_WORKER_ARG "--xompworker" 15 16/* XOMP channel settings */ 17 18/// size of the messaging channel between master and remote workers 19#define XOMP_MSG_CHAN_SIZE 4096 20 21/// size of the thread local storage frame 22#define XOMP_TLS_SIZE 4096 23 24/// size of the messaging frame (2x channel size) 25#define XOMP_MSG_FRAME_SIZE (2* XOMP_MSG_CHAN_SIZE) 26 27/// total size of the frame to allocate 28#define XOMP_FRAME_SIZE (XOMP_MSG_FRAME_SIZE + XOMP_TLS_SIZE) 29 30/// enables the XOMP worker to enable DMA 31#define XOMP_WORKER_ENABLE_DMA 1 32 33/// flag telling the function address is an index 34#define XOMP_FN_INDEX_FLAG (1UL << 63) 35 36/// ram affinity minimum base address 37#define XOMP_RAM_MIN_BASE (64UL * 1024 * 1024 * 1024) 38 39/// ram affinitiy maximum base address 40#define XOMP_RAM_MAX_LIMIT (512UL * 1024 * 1024 * 1024) 41 42/// enables the virtual threads 43#define XOMP_VTHREAD_COUNT 0 44 45/// enable the benchmarking 46#define XOMP_BENCH_ENABLED 0 47 48/// core on which to spawn remote workers 49#define XOMP_REMOTE_COREID_START 1 50 51/* Typedefs */ 52 53/// XOMP worker ID 54typedef uint64_t xomp_wid_t; 55 56/// XOMP task ID 57typedef uint32_t xomp_task_id_t; 58 59/// possible frame types when adding a new shared frame 60typedef enum xomp_frame_type { 61 XOMP_FRAME_TYPE_SHARED_RW, 62 XOMP_FRAME_TYPE_SHARED_RO, 63 XOMP_FRAME_TYPE_REPL_RW, 64 XOMP_FRAME_TYPE_REPL_RO, 65 XOMP_FRAME_TYPE_MSG 66} xomp_frame_type_t; 67 68/// controls where the worker are spawned 69typedef enum xomp_worker_loc { 70 XOMP_WORKER_LOC_INVALID = 0, 71 XOMP_WORKER_LOC_MIXED, ///< spawn remote and local 72 XOMP_WORKER_LOC_REMOTE, ///< spawn remote only 73 XOMP_WORKER_LOC_LOCAL ///< spawn local only 74} xomp_wloc_t; 75 76typedef enum xomp_arg_type { 77 XOMP_ARG_TYPE_WORKER, 78 XOMP_ARG_TYPE_UNIFORM, 79 XOMP_ARG_TYPE_DISTINCT, 80} xomp_arg_t; 81 82/// XOMP worker function 83typedef void (*xomp_worker_fn_t) (void *); 84 85/** 86 * XOMP task structure 87 */ 88struct xomp_task 89{ 90 xomp_task_id_t id; ///< id of the task 91 uint32_t total_threads; ///< total workers used in this task 92 uint32_t done; ///< number of workers that have completed 93 void *barrier; ///< the barrier to enter upon completion 94 void *arg; ///< argument of the worker function 95 xomp_worker_fn_t fn; ///< worker function to be called 96}; 97 98/** 99 * \brief represents the arguments and path of the worker domains 100 */ 101struct xomp_spawn { 102 uint8_t argc; 103 char **argv; 104 char *path; 105}; 106 107/** 108 * \brief arguments passed to the xomp initialization function 109 */ 110struct xomp_args 111{ 112 xomp_arg_t type; ///< the argument type 113 coreid_t core_stride; ///< core stride 114 union { 115 /// worker arguments 116 struct { 117 xomp_wid_t id; ///< the id of the worker 118 } worker; 119 120 /** uniform master arguments for local and remote workers */ 121 struct { 122 uint32_t nthreads; ///< number of threads 123 xomp_wloc_t worker_loc; ///< where the worker are spawned 124 uint8_t nphi; ///< number of xeon phis to use 125 uint8_t argc; ///< number of arguments 126 char **argv; ///< argument values 127 } uniform; 128 129 /** distinct master arguments for local and remote workers separatly */ 130 struct { 131 uint32_t nthreads; ///< number of threads 132 xomp_wloc_t worker_loc; ///< where the worker are spawned 133 uint8_t nphi; ///< number of xeon phis to use 134 struct xomp_spawn local; ///< arguments for the local workers 135 struct xomp_spawn remote; ///< arguments for hte remote workers 136 } distinct; 137 } args; 138}; 139 140/* include the master and worker */ 141#include <xomp/xomp_master.h> 142#include <xomp/xomp_worker.h> 143 144#endif // LIB_XOMP_H_ 145 146