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 "skc.h" 16 #include "runtime.h" 17 #include "cq_pool_cl.h" 18 #include "handle_pool_cl_12.h" 19 #include "block_pool_cl_12.h" 20 #include "allocator_device_cl.h" 21 22 // 23 // FIXME -- two parts: 24 // 25 // 1. directly access the structures in the runtime sub-struct implementations 26 // 2. possibly wall off the non-platform-specific structs into a sub structure 27 // 28 29 struct skc_runtime 30 { 31 // 32 // state visible to device 33 // 34 struct { 35 cl_context context; 36 cl_device_id device_id; 37 cl_uint align_bytes; 38 } cl; 39 40 struct { 41 struct skc_allocator_host host; 42 struct skc_allocator_device device; 43 } allocator; 44 45 struct skc_cq_pool cq_pool; 46 47 struct skc_block_pool block_pool; 48 49 struct skc_handle_pool handle_pool; 50 51 // 52 // state that is slightly opaque (for now) 53 // 54 struct skc_scheduler * scheduler; 55 56 struct skc_grid_deps * deps; 57 58 struct skc_config const * config; // FIXME: config will be determined by device with some opportunities to resize 59 60 struct skc_device * device; // opaque bundle of kernels 61 62 struct hs_cl const * hs; // opaque hotsort 63 }; 64 65 // 66 // Creation and disposal intitializes context and may rely on other 67 // context resources like the scheduler 68 // 69 70 skc_err 71 skc_runtime_cl_12_create(struct skc_context * const context, 72 cl_context context_cl, 73 cl_device_id device_id_cl); 74 75 skc_err 76 skc_runtime_cl_12_dispose(struct skc_context * const context); 77 78 // 79 // HOST HANDLE RETAIN/RELEASE/FLUSH 80 // 81 82 skc_err 83 skc_runtime_path_host_retain(struct skc_runtime * const runtime, 84 skc_path_t const * paths, 85 uint32_t count); 86 87 skc_err 88 skc_runtime_raster_host_retain(struct skc_runtime * const runtime, 89 skc_raster_t const * rasters, 90 uint32_t count); 91 92 93 skc_err 94 skc_runtime_path_host_release(struct skc_runtime * const runtime, 95 skc_path_t const * paths, 96 uint32_t count); 97 98 skc_err 99 skc_runtime_raster_host_release(struct skc_runtime * const runtime, 100 skc_raster_t const * rasters, 101 uint32_t count); 102 103 104 skc_err 105 skc_runtime_path_host_flush(struct skc_runtime * const runtime, 106 skc_path_t const * paths, 107 uint32_t count); 108 109 skc_err 110 skc_runtime_raster_host_flush(struct skc_runtime * const runtime, 111 skc_raster_t const * rasters, 112 uint32_t count); 113 114 // 115 // DEVICE/PIPELINE HANDLE ACQUIRE/RETAIN/RELEASE 116 // 117 // The retain operations pre-validate handles 118 // 119 120 skc_handle_t 121 skc_runtime_handle_device_acquire(struct skc_runtime * const runtime); 122 123 skc_err 124 skc_runtime_handle_device_validate_retain(struct skc_runtime * const runtime, 125 skc_typed_handle_type_e const handle_type, 126 skc_typed_handle_t const * typed_handles, 127 uint32_t count); 128 129 void 130 skc_runtime_handle_device_retain(struct skc_runtime * const runtime, 131 skc_handle_t const * handles, 132 uint32_t count); 133 134 void 135 skc_runtime_path_device_release(struct skc_runtime * const runtime, 136 skc_handle_t const * handles, 137 uint32_t count); 138 139 void 140 skc_runtime_raster_device_release(struct skc_runtime * const runtime, 141 skc_handle_t const * handles, 142 uint32_t count); 143 144 // 145 // We only use in-order command queues in the pipeline 146 // 147 148 cl_command_queue 149 skc_runtime_acquire_cq_in_order(struct skc_runtime * const runtime); 150 151 void 152 skc_runtime_release_cq_in_order(struct skc_runtime * const runtime, 153 cl_command_queue cq); 154 155 // 156 // DEVICE MEMORY ALLOCATION 157 // 158 159 cl_mem 160 skc_runtime_device_perm_alloc(struct skc_runtime * const runtime, 161 cl_mem_flags const flags, 162 size_t const size); 163 164 void 165 skc_runtime_device_perm_free(struct skc_runtime * const runtime, 166 cl_mem const mem); 167 168 cl_mem 169 skc_runtime_device_temp_alloc(struct skc_runtime * const runtime, 170 cl_mem_flags const flags, 171 size_t const size, 172 skc_subbuf_id_t * const subbuf_id, 173 size_t * const subbuf_size); 174 175 void 176 skc_runtime_device_temp_free(struct skc_runtime * const runtime, 177 cl_mem const mem, 178 skc_subbuf_id_t const subbuf_id); 179 180 // 181 // 182 // 183 184 void 185 skc_runtime_cl_12_debug(struct skc_context * const context); 186 187 // 188 // 189 // 190