1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can 5 * be found in the LICENSE file. 6 * 7 */ 8 9 #pragma once 10 11 // 12 // 13 // 14 15 #include "handle.h" 16 #include "scheduler.h" 17 18 // 19 // The requirement is that every grid struct begin with an skc_grid_t 20 // 21 22 typedef struct skc_grid * skc_grid_t; 23 typedef struct skc_grid_deps * skc_grid_deps_t; 24 25 // 26 // 27 // 28 29 typedef void (* skc_grid_pfn)(skc_grid_t const grid); 30 31 // 32 // 33 // 34 35 #define SKC_IS_GRID_INVALID(grid) (grid == NULL) 36 37 // 38 // 39 // 40 41 #define SKC_GRID_DEPS_ATTACH(deps,addr,data,waiting_pfn,execute_pfn,dispose_pfn) \ 42 skc_grid_deps_attach(deps,addr,data, \ 43 waiting_pfn,execute_pfn,dispose_pfn, \ 44 #waiting_pfn,#execute_pfn,#dispose_pfn) \ 45 // 46 // 47 // 48 49 skc_grid_deps_t 50 skc_grid_deps_create(struct skc_runtime * const runtime, 51 struct skc_scheduler * const scheduler, 52 skc_uint const handle_pool_size); 53 54 void 55 skc_grid_deps_dispose(skc_grid_deps_t const deps); 56 57 // 58 // 59 // 60 61 #ifndef NDEBUG 62 void 63 skc_grid_deps_debug(struct skc_grid_deps const * const deps); 64 #endif 65 66 // 67 // 68 // 69 70 skc_grid_t 71 skc_grid_deps_attach(skc_grid_deps_t const deps, 72 skc_grid_t * const addr, 73 void * const data, 74 skc_grid_pfn waiting_pfn, // upon READY > WAITING 75 skc_grid_pfn execute_pfn, // upon READY/WAITING > EXECUTING 76 skc_grid_pfn dispose_pfn, // upon EXECUTING > COMPLETE 77 char const * const waiting_name, 78 char const * const execute_name, 79 char const * const dispose_name); 80 81 #if 0 82 // 83 // Not using this yet -- needs to properly detach and reclaim a ready 84 // grid's resources 85 // 86 void 87 skc_grid_detach(skc_grid_t const grid); 88 #endif 89 90 // 91 // 92 // 93 94 void * 95 skc_grid_get_data(skc_grid_t const grid); 96 97 void 98 skc_grid_set_data(skc_grid_t const grid, void * const data); 99 100 // 101 // 102 // 103 104 void 105 skc_grid_map(skc_grid_t const grid, skc_handle_t const handle); 106 107 // 108 // 109 // 110 111 void 112 skc_grid_deps_force(skc_grid_deps_t const deps, 113 skc_handle_t const * const handles, 114 skc_uint const count); 115 116 void 117 skc_grid_deps_unmap(skc_grid_deps_t const deps, 118 skc_handle_t const * const handles, 119 skc_uint const count); 120 121 // 122 // 123 // 124 125 void 126 skc_grid_happens_after_grid(skc_grid_t const after, 127 skc_grid_t const before); 128 129 void 130 skc_grid_happens_after_handle(skc_grid_t const after, 131 skc_handle_t const before); 132 133 // 134 // should be called by host 135 // 136 137 void 138 skc_grid_start(skc_grid_t const grid); 139 140 void 141 skc_grid_force(skc_grid_t const grid); 142 143 // 144 // should be called by the scheduler 145 // 146 147 void 148 skc_grid_complete(skc_grid_t const grid); 149 150 // 151 // 152 // 153 154 #if 0 155 // 156 // delete when ready 157 // 158 skc_grid_t 159 skc_grid_move(skc_grid_t const grid, 160 skc_grid_state_e * const state, 161 skc_grid_t * const addr, 162 void * const data); 163 #endif 164 165 // 166 // 167 // 168