aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/skc/platforms/cl_12/runtime_cl_12.h
blob: 7e7ffcb2847d28aecb023acbe09256e23fb02e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can
 * be found in the LICENSE file.
 *
 */

#pragma once

//
//
//

#include "runtime.h"
#include "runtime_cl.h"
#include "cq_pool_cl.h"
#include "handle_pool_cl_12.h"
#include "block_pool_cl_12.h"
#include "allocator_device_cl.h"

//
// FIXME -- two parts:
//
// 1. directly access the structures in the runtime sub-struct implementations
// 2. possibly wall off the non-platform-specific structs into a sub structure
//

struct skc_runtime
{
  //
  // state visible to device
  //
  struct skc_runtime_cl            cl;

  struct {
    struct skc_allocator_host      host;
    struct skc_allocator_device    device;
  } allocator;

  struct skc_cq_pool               cq_pool;

  struct skc_block_pool            block_pool;

  struct skc_handle_pool           handle_pool;

  //
  // state that is slightly opaque (for now)
  //
  struct skc_scheduler           * scheduler;

  struct skc_grid_deps           * deps;

  struct skc_config const        * config; // FIXME: config will be determined by device with some opportunities to resize

  struct skc_device              * device; // opaque bundle of kernels
};

//
// Creation and disposal intitializes context and may rely on other
// context resources like the scheduler
//

skc_err
skc_runtime_cl_12_create(struct skc_context * const context,
                         char const         * const target_platform_substring,
                         char const         * const target_device_substring,
                         cl_context_properties      context_properties[]);

skc_err
skc_runtime_cl_12_dispose(struct skc_context * const context);

//
// HOST HANDLE RETAIN/RELEASE/FLUSH
//

skc_err
skc_runtime_path_host_retain(struct skc_runtime * const runtime,
                             skc_path_t   const *       paths,
                             uint32_t                   count);

skc_err
skc_runtime_raster_host_retain(struct skc_runtime * const runtime,
                               skc_raster_t const *       rasters,
                               uint32_t                   count);


skc_err
skc_runtime_path_host_release(struct skc_runtime * const runtime,
                              skc_path_t   const *       paths,
                              uint32_t                   count);

skc_err
skc_runtime_raster_host_release(struct skc_runtime * const runtime,
                                skc_raster_t const *       rasters,
                                uint32_t                   count);


skc_err
skc_runtime_path_host_flush(struct skc_runtime * const runtime,
                            skc_path_t   const *       paths,
                            uint32_t                   count);

skc_err
skc_runtime_raster_host_flush(struct skc_runtime * const runtime,
                              skc_raster_t const *       rasters,
                              uint32_t                   count);

//
// DEVICE/PIPELINE HANDLE ACQUIRE/RETAIN/RELEASE
//
// The retain operations pre-validate handles
//

skc_handle_t
skc_runtime_handle_device_acquire(struct skc_runtime * const runtime);

skc_err
skc_runtime_handle_device_validate_retain(struct skc_runtime       * const runtime,
                                          skc_typed_handle_type_e    const handle_type,
                                          skc_typed_handle_t const *       typed_handles,
                                          uint32_t                         count);

void
skc_runtime_handle_device_retain(struct skc_runtime * const runtime,
                                 skc_handle_t const *       handles,
                                 uint32_t                   count);

void
skc_runtime_path_device_release(struct skc_runtime * const runtime,
                                skc_handle_t const *       handles,
                                uint32_t                   count);

void
skc_runtime_raster_device_release(struct skc_runtime * const runtime,
                                  skc_handle_t const *       handles,
                                  uint32_t                   count);

//
// We only use in-order command queues in the pipeline
//

cl_command_queue
skc_runtime_acquire_cq_in_order(struct skc_runtime * const runtime);

void
skc_runtime_release_cq_in_order(struct skc_runtime * const runtime,
                                cl_command_queue           cq);

//
// DEVICE MEMORY ALLOCATION
//

cl_mem
skc_runtime_device_perm_alloc(struct skc_runtime * const runtime,
                              cl_mem_flags         const flags,
                              size_t               const size);

void
skc_runtime_device_perm_free(struct skc_runtime * const runtime,
                             cl_mem               const mem);

cl_mem
skc_runtime_device_temp_alloc(struct skc_runtime * const runtime,
                              cl_mem_flags         const flags,
                              size_t               const size,
                              skc_subbuf_id_t    * const subbuf_id,
                              size_t             * const subbuf_size);

void
skc_runtime_device_temp_free(struct skc_runtime * const runtime,
                             cl_mem               const mem,
                             skc_subbuf_id_t      const subbuf_id);

//
//
//