HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CE_SnippetKernelBind.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CE_SnippetImpl.h ( CE Library, C++)
7  *
8  * COMMENTS: Implementation of snippet manipulation for OpenCL
9  */
10 
11 #ifndef __CE_SnippetKernelBind__
12 #define __CE_SnippetKernelBind__
13 
14 #include "CE_API.h"
15 #include "CE_Context.h"
16 #include "CE_Snippet.h"
17 #include "CE_RampCache.h"
18 #include <UT/UT_WorkBuffer.h>
19 #include <UT/UT_ErrorManager.h>
20 #include <UT/UT_Debug.h>
21 
22 namespace CE_Snippet
23 {
24  template <CE_Precision PREC, typename OP>
25  bool setKernelArgument(const Binding &binding, int p,
26  cl::Kernel &kernel, int &argidx,
27  UT_Array<cl::Buffer> &owned_buffers,
28  UT_Array<cl::Buffer> &referenced_buffers,
29  fpreal timestep,
30  UT_ErrorManager *error,
31  UT_ErrorSeverity missingseverity,
32  const OP &op);
33 
34  /// Binds each of the bindings in turn.
35  /// OP is a callback structure that knows how to bind the various
36  /// bespoke types, with
37  /// bool operator()(const CE_Snippet::Binding &binding, int p,
38  /// cl::Kernel &kernel, int &argidx,
39  /// UT_ErrorManager *error,
40  /// CE_Precision PREC)
41  template <typename OP>
42  inline bool setKernelArguments(const UT_Array<Binding> &bindings,
43  BindingPrecision nodeprecision,
44  cl::Kernel &kernel, int &argidx,
45  UT_Array<cl::Buffer> &owned_buffers,
46  UT_Array<cl::Buffer> &referenced_buffers,
47  fpreal timestep,
48  UT_ErrorManager *error,
49  UT_ErrorSeverity missingseverity,
50  const OP &op)
51  {
52  bool ok = true;
53  int p = 0;
54  for (auto && binding : bindings)
55  {
56  auto precision = binding.precision;
58  precision = nodeprecision;
59  switch (precision)
60  {
62  UT_ASSERT(!"This should have been handled");
63  break;
65  ok &= setKernelArgument<CE_16, OP>(binding, p, kernel, argidx, owned_buffers, referenced_buffers, timestep, error, missingseverity, op);
66  break;
68  ok &= setKernelArgument<CE_32, OP>(binding, p, kernel, argidx, owned_buffers, referenced_buffers, timestep, error, missingseverity, op);
69  break;
71  ok &= setKernelArgument<CE_64, OP>(binding, p, kernel, argidx, owned_buffers, referenced_buffers, timestep, error, missingseverity, op);
72  break;
73 
74  }
75  if (!ok)
76  break;
77  p++;
78  }
79  return ok;
80  }
81 
82  /// Adds an error to the error manager for mis-binding an argument.
83  CE_API void reportSetArgError(const char *name, int argidx,
84  int pidx, const char *type,
85  const char *extra, UT_ErrorManager *error);
86 
87  template <typename TYPE>
88  inline void bindKernelArgRaw(TYPE *val, int tuplesize,
89  cl::Kernel &kernel, int &argidx,
90  const char *name, const char *type, int pidx,
91  UT_ErrorManager *error,
92  const char *extra = 0)
93  {
94  try
95  {
96  kernel.setArg( argidx, tuplesize * sizeof(TYPE), val);
97  argidx++;
98  }
99  catch (cl::Error &)
100  {
101  reportSetArgError(name, argidx, pidx, type, extra, error);
102  throw;
103  }
104  }
105  /// Binds a kernel argument of the type, incrementing the argidx
106  /// Will throw an error and add the error to the provided error manager.
107  ///{
108  inline void bindKernelArgI(cl_int val, cl::Kernel &kernel, int &argidx,
109  const char *name, int pidx, UT_ErrorManager *error,
110  const char *extra = 0)
111  { bindKernelArgRaw(&val, 1, kernel, argidx, name, "int", pidx, error, extra); }
112  inline void bindKernelArgI2(cl_int *val, cl::Kernel &kernel, int &argidx,
113  const char *name, int pidx, UT_ErrorManager *error,
114  const char *extra = 0)
115  { bindKernelArgRaw(val, 2, kernel, argidx, name, "int2", pidx, error, extra); }
116  inline void bindKernelArgI4(cl_int *val, cl::Kernel &kernel, int &argidx,
117  const char *name, int pidx, UT_ErrorManager *error,
118  const char *extra = 0)
119  { bindKernelArgRaw(val, 4, kernel, argidx, name, "int4", pidx, error, extra); }
120  inline void bindKernelArgF(cl_float val, cl::Kernel &kernel, int &argidx,
121  const char *name, int pidx, UT_ErrorManager *error,
122  const char *extra = 0)
123  { bindKernelArgRaw(&val, 1, kernel, argidx, name, "float", pidx, error, extra); }
124  inline void bindKernelArgV2(cl_float *val, cl::Kernel &kernel, int &argidx,
125  const char *name, int pidx, UT_ErrorManager *error,
126  const char *extra = 0)
127  { bindKernelArgRaw(val, 2, kernel, argidx, name, "float2", pidx, error, extra); }
128  /// NOTE: This binds float4 due to vagaries of cl!
129  inline void bindKernelArgV3(cl_float *val, cl::Kernel &kernel, int &argidx,
130  const char *name, int pidx, UT_ErrorManager *error,
131  const char *extra = 0)
132  { bindKernelArgRaw(val, 4, kernel, argidx, name, "float3", pidx, error, extra); }
133  inline void bindKernelArgV4(cl_float *val, cl::Kernel &kernel, int &argidx,
134  const char *name, int pidx, UT_ErrorManager *error,
135  const char *extra = 0)
136  { bindKernelArgRaw(val, 4, kernel, argidx, name, "float4", pidx, error, extra); }
137  inline void bindKernelArgV16(cl_float *val, cl::Kernel &kernel, int &argidx,
138  const char *name, int pidx, UT_ErrorManager *error,
139  const char *extra = 0)
140  { bindKernelArgRaw(val, 16, kernel, argidx, name, "float16", pidx, error, extra); }
141  inline void bindKernelArgB(cl::Buffer val, cl::Kernel &kernel, int &argidx,
142  const char *name, int pidx, const char *type,
143  UT_ErrorManager *error,
144  const char *extra = 0)
145  {
146  try
147  {
148  kernel.setArg( argidx, val);
149  argidx++;
150  }
151  catch (cl::Error &)
152  {
153  reportSetArgError(name, argidx, pidx, type, extra, error);
154  throw;
155  }
156  }
157 
158  ///}
159  template <CE_Precision PREC, typename OP>
160  inline bool
162  int p,
163  cl::Kernel &kernel, int &argidx,
164  UT_Array<cl::Buffer> &owned_buffers,
165  UT_Array<cl::Buffer> &referenced_buffers,
166  fpreal timestep,
167  UT_ErrorManager *error,
168  UT_ErrorSeverity missingseverity,
169  const OP &op)
170  {
171  bool ok = true;
172  UT_String retrieveStr;
173 
174  BindingType paramtype = BindingType::INVALID;
175  CEfloatH<PREC> param_float = 0;
176  CE_Context *clcontext = CE_Context::getContext();
177  CEintH<PREC> param_int;
178  UT_Vector4D param_float4;
179  UT_Vector3D param_float3;
180  UT_Vector2D param_float2;
181  UT_String param_string;
182 
183  CEfloatH<PREC> param_fpreal_array[16];
184 
185  paramtype = binding.type;
186 
187  // set base parameter values
188  switch (paramtype)
189  {
190  // Single integer
191  case BindingType::INT:
192  param_int = binding.intval;
193  CE_Snippet::bindKernelArgRaw(&param_int, 1,
194  kernel, argidx, binding.name, "int", p, error);
195  break;
196 
198  {
199  const cl_int array_size = binding.intarray.entries();
200  const int tuplesize = 1;
201 
202  UT_Array<CEintH<PREC>> array;
203  array.entries(array_size * tuplesize);
204 
205  int n = binding.intarray.entries();
206  for (int i = 0; i < n; i++)
207  array(i) = binding.intarray(i);
208 
209  const size_t array_data_size = array_size * tuplesize * sizeof( CEintH<PREC> );
210  // Bind null if empty.
211  cl::Buffer array_buffer;
212  if (array_data_size)
213  array_buffer = clcontext->allocBuffer(array_data_size);
214 
215  // Blocking since we will free our array shortly.
216  clcontext->writeBuffer( array_buffer, array_data_size, array.array() );
217  owned_buffers.append(array_buffer);
218 
219  CE_Snippet::bindKernelArgI(array_size, kernel, argidx, binding.name, p, error, "size");
220  CE_Snippet::bindKernelArgB(array_buffer, kernel, argidx, binding.name, p, "int *", error, "data");
221  break;
222  }
223 
224  // Single Float
225  case BindingType::FLOAT:
226  {
227  BindingTimescale timemethod;
228  param_float = binding.fval;
229  timemethod = binding.timescale;
230 
231  switch( timemethod )
232  {
233  case BindingTimescale::NONE: // None
234  break;
235  case BindingTimescale::MULT: // * Timescale
236  param_float *= timestep;
237  break;
238  case BindingTimescale::INVERT: // 1 / Timescale
239  param_float /= timestep;
240  break;
241  case BindingTimescale::POW: // e ^ timestep
242  param_float = SYSexp( param_float * timestep );
243  break;
244  default:
245  break;
246  }
247 
248  CE_Snippet::bindKernelArgRaw(&param_float, 1,
249  kernel, argidx, binding.name, "float", p, error);
250  break;
251  }
252 
253  // Float Vector 2
254  case BindingType::FLOAT2:
255  param_float2 = binding.v2val;
256  param_fpreal_array[0] = param_float2(0);
257  param_fpreal_array[1] = param_float2(1);
258 
259  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 2,
260  kernel, argidx, binding.name, "float2", p, error);
261  break;
262 
263  // Float Vector 3
264  case BindingType::FLOAT3:
265  param_float3 = binding.v3val;
266  param_fpreal_array[0] = param_float3(0);
267  param_fpreal_array[1] = param_float3(1);
268  param_fpreal_array[2] = param_float3(2);
269  param_fpreal_array[3] = 0;
270 
271  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
272  kernel, argidx, binding.name, "float3", p, error);
273  break;
274 
275  // Float Vector 4
276  case BindingType::FLOAT4:
277  param_float4 = binding.v4val;
278  param_fpreal_array[0] = param_float4(0);
279  param_fpreal_array[1] = param_float4(1);
280  param_fpreal_array[2] = param_float4(2);
281  param_fpreal_array[3] = param_float4(3);
282  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
283  kernel, argidx, binding.name, "float4", p, error);
284  break;
285 
286  // Float vector 8
287  case BindingType::FLOAT8:
288  param_float4 = binding.v4val;
289  param_fpreal_array[0] = param_float4(0);
290  param_fpreal_array[1] = param_float4(1);
291  param_fpreal_array[2] = param_float4(2);
292  param_fpreal_array[3] = param_float4(3);
293  param_float4 = binding.v4bval;
294  param_fpreal_array[4+0] = param_float4(0);
295  param_fpreal_array[4+1] = param_float4(1);
296  param_fpreal_array[4+2] = param_float4(2);
297  param_fpreal_array[4+3] = param_float4(3);
298  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 8,
299  kernel, argidx, binding.name, "float8", p, error);
300  break;
301 
302  // Float vector 16
304  {
305  for (int r = 0; r < 4; r++)
306  for (int c = 0; c < 4; c++)
307  param_fpreal_array[r*4+c] = binding.m4val(r, c);
308  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 16,
309  kernel, argidx, binding.name, "float8", p, error);
310  break;
311  }
312 
313  case BindingType::RAMP:
314  {
315  const cl_int ramp_size = binding.rampsize;
316  const int tuplesize = binding.ramptype == BindingRampType::VECTOR ? 3 : 1;
317 
318  const size_t ramp_data_size = ramp_size * tuplesize * sizeof( CEfloatH<PREC> );
319  cl::Buffer ramp_buffer;
320 
321  // load the ramp, allocate the required buffer, and populate
322  // with ramp data
323  if (binding.ramp)
324  {
325  // Check our cache...
326 
327  ramp_buffer = CEgetRampCache()->lookupRamp(binding.ramp, tuplesize, ramp_size);
328 
329  // Ensure the buffer remains live until dispatch.
330  if (ramp_buffer() != 0)
331  {
332  referenced_buffers.append(ramp_buffer);
333  }
334  }
335 
336  if (ramp_buffer() == 0)
337  {
338  UT_Array<CEfloatH<PREC>> ramp_array;
339  ramp_array.entries(ramp_size * tuplesize);
340 
341  if (binding.ramp)
342  {
343  int writepos = 0;
344  for (int i = 0; i < ramp_size; i++)
345  {
346  float values[4];
347  fpreal pos = i / fpreal(ramp_size - 1);
348  binding.ramp->rampLookup( pos, values );
349  for (int j = 0; j < tuplesize; j++)
350  ramp_array(writepos++) = values[j];
351  }
352  }
353  else if (binding.rampdata.entries())
354  {
355  UT_ASSERT(binding.rampdata.entries() == ramp_array.entries());
356  int n = SYSmin(binding.rampdata.entries(), ramp_array.entries());
357  for (int i = 0; i < n; i++)
358  ramp_array(i) = binding.rampdata(i);
359  for (int i = n; i < ramp_array.entries(); i++)
360  ramp_array(i) = 0;
361  }
362  else
363  {
364  ramp_array.constant(0);
365  }
366 
367  ramp_buffer = clcontext->allocBuffer(ramp_data_size);
368  // Blocking since we will free our array shortly.
369  clcontext->writeBuffer( ramp_buffer, ramp_data_size, ramp_array.array() );
370 
371  // Add to cache
372  if (binding.ramp)
373  {
374  CEgetRampCache()->cacheRamp(ramp_buffer, binding.ramp, tuplesize, ramp_size);
375  // WE need to keep the buffer live until dispatch
376  // but we don't want it returned to the pool
377  referenced_buffers.append(ramp_buffer);
378  }
379  else
380  {
381  // The buffer list is for the releaseBuffer,
382  // if we got it from the cache it is up to the
383  // cache to release it.
384  owned_buffers.append(ramp_buffer);
385  }
386  }
387 
388  CE_Snippet::bindKernelArgI(ramp_size, kernel, argidx, binding.name, p, error, "size");
389  CE_Snippet::bindKernelArgB(ramp_buffer, kernel, argidx, binding.name, p, "float *", error, "data");
390 
391  break;
392  }
393 
397  {
398  // Ignore unbound optional volumes
399  if (!op(binding, p, kernel, argidx, error, PREC))
400  {
401  UT_WorkBuffer msg;
402  msg.sprintf("Invalid field '%s'", (const char *) binding.fieldname);
403  if (missingseverity != UT_ERROR_NONE)
404  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
405  return false;
406  }
407 
408  break;
409  }
411  {
412  // Fetch our geometry
413  BindingAttribType atype = binding.attribtype;
414  int tuplesize = binding.attribsize;
415  bool isarray = atype == BindingAttribType::FLOATARRAY || atype == BindingAttribType::INTARRAY;
416  bool optional = binding.optional;
417 
418  if (!op(binding, p, kernel, argidx, error, PREC))
419  {
420  if (!optional)
421  {
422  UT_WorkBuffer msg;
423  msg.sprintf("Invalid attribute '%s'", (const char *) binding.attribute);
424  if (missingseverity != UT_ERROR_NONE)
425  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
426  return false;
427  }
428  else
429  {
430  // Check if we are to bind a default value...
431  if (!isarray && binding.defval)
432  {
433  if (atype == BindingAttribType::INT)
434  {
435  // Single integer
436  param_int = binding.intval;
437  CE_Snippet::bindKernelArgRaw(&param_int, 1,
438  kernel, argidx, binding.name, "int", p, error);
439  }
440  else if (tuplesize == 2)
441  {
442  param_float2 = binding.v2val;
443  param_fpreal_array[0] = param_float2(0);
444  param_fpreal_array[1] = param_float2(1);
445 
446  CE_Snippet::bindKernelArgRaw( param_fpreal_array, 2,
447  kernel, argidx, binding.name, "float2", p, error);
448  }
449  else if (tuplesize == 3)
450  {
451  // Float Vector 3
452  param_float3 = binding.v3val;
453  param_fpreal_array[0] = param_float3(0);
454  param_fpreal_array[1] = param_float3(1);
455  param_fpreal_array[2] = param_float3(2);
456  param_fpreal_array[3] = 0;
457 
458  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
459  kernel, argidx, binding.name, "float3", p, error);
460  }
461  else if (tuplesize == 4)
462  {
463  // Float Vector 4
464  param_float4 = binding.v4val;
465  param_fpreal_array[0] = param_float4(0);
466  param_fpreal_array[1] = param_float4(1);
467  param_fpreal_array[2] = param_float4(2);
468  param_fpreal_array[3] = param_float4(3);
469  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
470  kernel, argidx, binding.name, "float4", p, error);
471  }
472  else
473  {
474  // All other bind a single float default
475  param_float = binding.fval;
476  CE_Snippet::bindKernelArgRaw(&param_float, 1,
477  kernel, argidx, binding.name, "float", p, error);
478  }
479  }
480 
481  return true;
482  }
483  }
484 
485  break;
486  }
487 
488  case BindingType::VOLUME:
489  {
490  bool optional = binding.optional;
491 
492  // Ignore unbound optional volumes
493  if (!op(binding, p, kernel, argidx, error, PREC))
494  {
495  if (optional)
496  {
497  // Check if we are to bind a default value...
498  if (binding.defval)
499  {
500  param_float = binding.fval;
501  CE_Snippet::bindKernelArgRaw(&param_float, 1,
502  kernel, argidx, binding.name, "float", p, error);
503  }
504  return true;
505  }
506  else
507  {
508  UT_WorkBuffer msg;
509  msg.sprintf("Invalid volume '%s'", (const char *) binding.volume);
510  if (missingseverity != UT_ERROR_NONE)
511  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
512  return false;
513  }
514  }
515 
516  break;
517  }
518 
519  case BindingType::VDB:
520  {
521  bool optional = binding.optional;
522 
523  // Ignore unbound optional volumes
524  if (!op(binding, p, kernel, argidx, error, PREC))
525  {
526  if (!optional)
527  {
528  UT_WorkBuffer msg;
529  msg.sprintf("Invalid vdb '%s'", (const char *) binding.volume);
530  if (missingseverity != UT_ERROR_NONE)
531  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
532  return false;
533  }
534  else
535  {
536  // Check if we are to bind a default value...
537  if (binding.defval)
538  {
539  param_float = binding.fval;
540  CE_Snippet::bindKernelArgRaw(&param_float, 1,
541  kernel, argidx, binding.name, "float", p, error);
542  }
543  return true;
544  }
545  }
546  break;
547  }
548 
549  case BindingType::OPTION:
550  {
551  bool optional = binding.optional;
552  bool defval = binding.defval;
553  bool flttype = (binding.optiontype == BindingOptionType::FLOAT);
554  int tuplesize = binding.optionsize;
555 
556  // Ignore unbound optional volumes
557  if (!op(binding, p, kernel, argidx, error, PREC))
558  {
559  if (!optional)
560  {
561  UT_WorkBuffer msg;
562  msg.sprintf("Invalid option '%s'", (const char *) binding.optionname);
563  if (missingseverity != UT_ERROR_NONE)
564  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
565  return false;
566  }
567  else
568  {
569  // Check if we are to bind a default value...
570  if (defval)
571  {
572  if (!flttype)
573  {
574  // Integers are single value.
575  param_int = binding.intval;
576  CE_Snippet::bindKernelArgRaw(&param_int, 1,
577  kernel, argidx, binding.name, "int", p, error);
578  }
579  else if (tuplesize == 2)
580  {
581  param_float2 = binding.v2val;
582  param_fpreal_array[0] = param_float2(0);
583  param_fpreal_array[1] = param_float2(1);
584 
585  CE_Snippet::bindKernelArgRaw( param_fpreal_array, 2,
586  kernel, argidx, binding.name, "float2", p, error);
587  }
588  else if (tuplesize == 3)
589  {
590  // Float Vector 3
591  param_float3 = binding.v3val;
592  param_fpreal_array[0] = param_float3(0);
593  param_fpreal_array[1] = param_float3(1);
594  param_fpreal_array[2] = param_float3(2);
595  param_fpreal_array[3] = 0;
596 
597  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
598  kernel, argidx, binding.name, "float3", p, error);
599  }
600  else if (tuplesize == 4)
601  {
602  // Float Vector 4
603  param_float4 = binding.v4val;
604  param_fpreal_array[0] = param_float4(0);
605  param_fpreal_array[1] = param_float4(1);
606  param_fpreal_array[2] = param_float4(2);
607  param_fpreal_array[3] = param_float4(3);
608  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
609  kernel, argidx, binding.name, "float4", p, error);
610  }
611  else
612  {
613  // All other bind a single float default
614  param_float = binding.fval;
615  CE_Snippet::bindKernelArgRaw(&param_float, 1,
616  kernel, argidx, binding.name, "float", p, error);
617  }
618  }
619  return true;
620  }
621  }
622  break;
623  }
624 
625  case BindingType::LAYER:
626  {
627  bool optional = binding.optional;
628  bool defval = binding.defval;
629 
630  // Ignore unbound optional volumes
631  if (!op(binding, p, kernel, argidx, error, PREC))
632  {
633  if (!optional)
634  {
635  UT_WorkBuffer msg;
636  msg.sprintf("Invalid image '%s'", (const char *) binding.name);
637  if (missingseverity != UT_ERROR_NONE)
638  error->addGeneric("Common", UT_ERROR_JUST_STRING, msg.buffer(), missingseverity);
639  return false;
640  }
641  else
642  {
643  if (defval)
644  {
645  switch (binding.layertype)
646  {
648  param_int = binding.intval;
649  CE_Snippet::bindKernelArgRaw(&param_int, 1,
650  kernel, argidx, binding.name, "int", p, error);
651  break;
653  param_float = binding.fval;
654  CE_Snippet::bindKernelArgRaw(&param_float, 1,
655  kernel, argidx, binding.name, "float", p, error);
656  break;
658  param_fpreal_array[0] = binding.v2val(0);
659  param_fpreal_array[1] = binding.v2val(1);
660  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 2,
661  kernel, argidx, binding.name, "float2", p, error);
662  break;
664  param_fpreal_array[0] = binding.v3val(0);
665  param_fpreal_array[1] = binding.v3val(1);
666  param_fpreal_array[2] = binding.v3val(2);
667  param_fpreal_array[3] = 0;
668  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
669  kernel, argidx, binding.name, "float3", p, error);
670  break;
671  default:
672  param_fpreal_array[0] = binding.v4val(0);
673  param_fpreal_array[1] = binding.v4val(1);
674  param_fpreal_array[2] = binding.v4val(2);
675  param_fpreal_array[3] = binding.v4val(3);
676  CE_Snippet::bindKernelArgRaw(param_fpreal_array, 4,
677  kernel, argidx, binding.name, "float4", p, error);
678  }
679  }
680  return true;
681  }
682  }
683  break;
684  }
685  default:
686  break;
687  }
688 
689  return ok;
690  }
691 
692 } /// namespace
693 
694 #endif
#define CE_API
Definition: CE_API.h:13
BindingType type
Definition: CE_Snippet.h:157
UT_StringHolder attribute
Definition: CE_Snippet.h:177
UT_StringHolder fieldname
Definition: CE_Snippet.h:165
void bindKernelArgB(cl::Buffer val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, const char *type, UT_ErrorManager *error, const char *extra=0)
typename CE_PrecisionResolver< P >::host_int_type CEintH
Definition: CE_Precision.h:67
UT_Matrix4D m4val
Definition: CE_Snippet.h:193
SYS_FORCE_INLINE const char * buffer() const
CE_API void reportSetArgError(const char *name, int argidx, int pidx, const char *type, const char *extra, UT_ErrorManager *error)
Adds an error to the error manager for mis-binding an argument.
void bindKernelArgF(cl_float val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
UT_ErrorSeverity
Definition: UT_Error.h:25
T * array()
Definition: UT_Array.h:846
int32_t cl_int
Definition: cl_platform.h:260
UT_StringHolder name
Definition: CE_Snippet.h:156
typename CE_PrecisionResolver< P >::host_float_type CEfloatH
Definition: CE_Precision.h:66
UT_Vector4D v4val
Definition: CE_Snippet.h:191
void writeBuffer(const cl::Buffer &buf, size_t size, const void *p, bool blocking=true, size_t offset=0)
Write the specified number of bytes to the buffer.
UT_Vector4D v4bval
Definition: CE_Snippet.h:192
UT_StringHolder optionname
Definition: CE_Snippet.h:199
void bindKernelArgV2(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
UT_Vector2D UT_Vector3D v3val
Definition: CE_Snippet.h:190
GLdouble n
Definition: glcorearb.h:2008
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
void bindKernelArgV3(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
NOTE: This binds float4 due to vagaries of cl!
static CE_Context * getContext(bool gl_shared=true, bool shared_fallback=true)
BindingOptionType optiontype
Definition: CE_Snippet.h:200
void bindKernelArgI4(cl_int *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
BindingLayerType layertype
Definition: CE_Snippet.h:163
CE_API CE_RampCache * CEgetRampCache()
bool setKernelArgument(const Binding &binding, int p, cl::Kernel &kernel, int &argidx, UT_Array< cl::Buffer > &owned_buffers, UT_Array< cl::Buffer > &referenced_buffers, fpreal timestep, UT_ErrorManager *error, UT_ErrorSeverity missingseverity, const OP &op)
}
cl::Buffer lookupRamp(UT_SharedPtr< UT_Ramp > ramp, int tuplesize, int rampsize)
GLuint const GLchar * name
Definition: glcorearb.h:786
UT_SharedPtr< UT_Ramp > ramp
Definition: CE_Snippet.h:158
cl::Buffer allocBuffer(int64 size, bool use_pool=true, bool read=true, bool write=true, uint32 ogl_bind=SYS_UINT32_MAX)
exint append()
Definition: UT_Array.h:142
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
BindingRampType ramptype
Definition: CE_Snippet.h:160
GLenum GLint GLint * precision
Definition: glcorearb.h:1925
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:655
float cl_float
Definition: cl_platform.h:266
GLint j
Definition: glad.h:2733
void bindKernelArgI(cl_int val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
void bindKernelArgI2(cl_int *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
BindingAttribType attribtype
Definition: CE_Snippet.h:179
UT_Array< int > intarray
Definition: CE_Snippet.h:162
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
fpreal64 fpreal
Definition: SYS_Types.h:278
bool setKernelArguments(const UT_Array< Binding > &bindings, BindingPrecision nodeprecision, cl::Kernel &kernel, int &argidx, UT_Array< cl::Buffer > &owned_buffers, UT_Array< cl::Buffer > &referenced_buffers, fpreal timestep, UT_ErrorManager *error, UT_ErrorSeverity missingseverity, const OP &op)
GLuint GLfloat * val
Definition: glcorearb.h:1608
void bindKernelArgV4(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
void cacheRamp(cl::Buffer buffer, UT_SharedPtr< UT_Ramp > ramp, int tuplesize, int rampsize)
Adds to the cache.
A global error manager scope.
Memory buffer interface.
Definition: cl.hpp:1867
UT_Vector2D v2val
Definition: CE_Snippet.h:189
void constant(const T &v)
Quickly set the array to a single value.
void bindKernelArgV16(cl_float *val, cl::Kernel &kernel, int &argidx, const char *name, int pidx, UT_ErrorManager *error, const char *extra=0)
cl_int setArg(cl_uint index, T value)
Definition: cl.hpp:2614
UT_Array< float > rampdata
Definition: CE_Snippet.h:159
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2544
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GLboolean r
Definition: glcorearb.h:1222
#define SYSmin(a, b)
Definition: SYS_Math.h:1583
void bindKernelArgRaw(TYPE *val, int tuplesize, cl::Kernel &kernel, int &argidx, const char *name, const char *type, int pidx, UT_ErrorManager *error, const char *extra=0)
UT_StringHolder volume
Definition: CE_Snippet.h:169
UT_ErrorSeverity addGeneric(const char *type, int code, const char *msg, UT_ErrorSeverity sev, const UT_SourceLocation *loc=0)
BindingTimescale timescale
Definition: CE_Snippet.h:197