[PATCH] D26509: [OpenCL] Fix integer parameters of enqueue_kernel

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 08:52:28 PST 2016


Anastasia created this revision.
Anastasia added a reviewer: yaxunl.
Anastasia added a subscriber: cfe-commits.

Parameters representing number of events as well as sizes of enqueued block arguments in enqueue_kernel function are specified as uint type. This prevents passing sizeof(int) type expressions on the  64 bit architectures because they return size_t which is a 64 bit wide in contrast to uint that is always 32 bits.

The suggestion is to accept any integer type as soon as the compiler can prove that the range fits in the data width of uint for number of event or size_t for block argument sizes (and if not appropriate error is emitted).

The proposed enqueue_kernel signature would be:

  int enqueue_kernel (queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, uint num_events_in_wait_list, const clk_event_t *event_wait_list, clk_event_t *event_ret, void (^block)(local void *, ...), size_t size0, ...)

and therefore compiler should allow the call:

  enqueue_kernel(default_queue, flags, ndrange, sizeof(event_wait_list)/sizeof(event_wait_list[0]), event_wait_list2, &clk_event,
                 ^(local void *p) {
                   return;
                 },
                 sizeof(int[2]));

See tests for more examples.


https://reviews.llvm.org/D26509

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26509.77496.patch
Type: text/x-patch
Size: 28088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161110/c3f815e8/attachment-0001.bin>


More information about the cfe-commits mailing list