Skip to content

Commit

Permalink
Support CL 1.1 again, test that support
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Nov 30, 2015
1 parent 90b73be commit 4bb4089
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 19 deletions.
13 changes: 13 additions & 0 deletions .gitlab-ci.yml
Expand Up @@ -73,6 +73,19 @@ Python 3.5 AMD Fiji:
- amd-fiji
except:
- tags
Python 3.5 POCL CL 1.1:
script:
- export PY_EXE=python3.5
- export PYOPENCL_TEST=portable
- export EXTRA_INSTALL="numpy mako"
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh
- ./configure.py --cl-pretend-version=1.1
- ". ./build-and-test-py-project.sh"
tags:
- python3.5
- pocl
except:
- tags
Python 2.7 POCL:
script:
- export PY_EXE=python2.7
Expand Down
26 changes: 20 additions & 6 deletions src/c_wrapper/buffer.cpp
Expand Up @@ -103,13 +103,13 @@ enqueue_copy_buffer(clobj_t *evt, clobj_t _queue, clobj_t _src, clobj_t _dst,
});
}

#if PYOPENCL_CL_VERSION >= 0x1020

error*
enqueue_fill_buffer(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *pattern,
size_t psize, size_t offset, size_t size,
const clobj_t *_wait_for, uint32_t num_wait_for)
{
#if PYOPENCL_CL_VERSION >= 0x1020
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
auto queue = static_cast<command_queue*>(_queue);
auto mem = static_cast<memory_object*>(_mem);
Expand All @@ -119,11 +119,11 @@ enqueue_fill_buffer(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *pattern,
psize, offset, size, wait_for,
event_out(evt));
});
}

#else
PYOPENCL_UNSUPPORTED(clEnqueueFillBuffer, "CL 1.1 and below")
#endif
}

#if PYOPENCL_CL_VERSION >= 0x1010

// {{{ rectangular transfers

Expand All @@ -137,6 +137,7 @@ enqueue_read_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *buf,
const clobj_t *_wait_for, uint32_t num_wait_for,
int block, void *pyobj)
{
#if PYOPENCL_CL_VERSION >= 0x1010
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
auto queue = static_cast<command_queue*>(_queue);
auto mem = static_cast<memory_object*>(_mem);
Expand All @@ -151,6 +152,9 @@ enqueue_read_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *buf,
host_orig, reg, buf_pitches[0], buf_pitches[1], host_pitches[0],
host_pitches[1], buf, wait_for, nanny_event_out(evt, pyobj));
});
#else
PYOPENCL_UNSUPPORTED(clEnqueueReadBufferRect, "CL 1.0")
#endif
}

error*
Expand All @@ -163,6 +167,7 @@ enqueue_write_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *buf,
const clobj_t *_wait_for, uint32_t num_wait_for,
int block, void *pyobj)
{
#if PYOPENCL_CL_VERSION >= 0x1010
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
auto queue = static_cast<command_queue*>(_queue);
auto mem = static_cast<memory_object*>(_mem);
Expand All @@ -177,6 +182,9 @@ enqueue_write_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *buf,
host_orig, reg, buf_pitches[0], buf_pitches[1], host_pitches[0],
host_pitches[1], buf, wait_for, nanny_event_out(evt, pyobj));
});
#else
PYOPENCL_UNSUPPORTED(clEnqueueWriteBufferRect, "CL 1.0")
#endif
}

error*
Expand All @@ -188,6 +196,7 @@ enqueue_copy_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _src,
const size_t *_dst_pitches, size_t dst_pitches_l,
const clobj_t *_wait_for, uint32_t num_wait_for)
{
#if PYOPENCL_CL_VERSION >= 0x1010
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
auto queue = static_cast<command_queue*>(_queue);
auto src = static_cast<memory_object*>(_src);
Expand All @@ -203,6 +212,9 @@ enqueue_copy_buffer_rect(clobj_t *evt, clobj_t _queue, clobj_t _src,
reg, src_pitches[0], src_pitches[1], dst_pitches[0],
dst_pitches[1], wait_for, event_out(evt));
});
#else
PYOPENCL_UNSUPPORTED(clEnqueueCopyBufferRect, "CL 1.0")
#endif
}

// }}}
Expand All @@ -211,10 +223,12 @@ error*
buffer__get_sub_region(clobj_t *_sub_buf, clobj_t _buf, size_t orig,
size_t size, cl_mem_flags flags)
{
#if PYOPENCL_CL_VERSION >= 0x1010
auto buf = static_cast<buffer*>(_buf);
return c_handle_error([&] {
*_sub_buf = buf->get_sub_region(orig, size, flags);
});
}

#else
PYOPENCL_UNSUPPORTED(clCreateSubBuffer, "CL 1.0")
#endif
}
10 changes: 8 additions & 2 deletions src/c_wrapper/command_queue.cpp
Expand Up @@ -81,31 +81,37 @@ command_queue__flush(clobj_t queue)
});
}

#if PYOPENCL_CL_VERSION >= 0x1020
error*
enqueue_marker_with_wait_list(clobj_t *evt, clobj_t _queue,
const clobj_t *_wait_for, uint32_t num_wait_for)
{
#if PYOPENCL_CL_VERSION >= 0x1020
auto queue = static_cast<command_queue*>(_queue);
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
return c_handle_error([&] {
pyopencl_call_guarded(clEnqueueMarkerWithWaitList, queue,
wait_for, event_out(evt));
});
#else
PYOPENCL_UNSUPPORTED(clEnqueueMarkerWithWaitList, "CL 1.1 and below")
#endif
}

error*
enqueue_barrier_with_wait_list(clobj_t *evt, clobj_t _queue,
const clobj_t *_wait_for, uint32_t num_wait_for)
{
#if PYOPENCL_CL_VERSION >= 0x1020
auto queue = static_cast<command_queue*>(_queue);
const auto wait_for = buf_from_class<event>(_wait_for, num_wait_for);
return c_handle_error([&] {
pyopencl_call_guarded(clEnqueueBarrierWithWaitList, queue,
wait_for, event_out(evt));
});
}
#else
PYOPENCL_UNSUPPORTED(clEnqueueBarrierWithWaitList, "CL 1.1 and below")
#endif
}

error*
enqueue_marker(clobj_t *evt, clobj_t _queue)
Expand Down
6 changes: 4 additions & 2 deletions src/c_wrapper/device.cpp
Expand Up @@ -288,17 +288,19 @@ device::create_sub_devices(const cl_device_partition_property *props)

// c wrapper

#if PYOPENCL_CL_VERSION >= 0x1020
error*
device__create_sub_devices(clobj_t _dev, clobj_t **_devs,
uint32_t *num_devices,
const cl_device_partition_property *props)
{
#if PYOPENCL_CL_VERSION >= 0x1020
auto dev = static_cast<device*>(_dev);
return c_handle_error([&] {
auto devs = dev->create_sub_devices(props);
*num_devices = (uint32_t)devs.len();
*_devs = devs.release();
});
}
#else
PYOPENCL_UNSUPPORTED(clCreateImage, "CL 1.1 and below")
#endif
}
2 changes: 1 addition & 1 deletion src/c_wrapper/error.h
Expand Up @@ -25,7 +25,7 @@
auto err = (error*)malloc(sizeof(error)); \
err->routine = strdup(#ROUTINE); \
err->msg = strdup("unsupported in " VERSION); \
err->code = CL_INVALID_VALUE \
err->code = CL_INVALID_VALUE; \
err->other = 0; \
return err;

Expand Down
6 changes: 4 additions & 2 deletions src/c_wrapper/image.cpp
Expand Up @@ -174,13 +174,13 @@ enqueue_write_image(clobj_t *evt, clobj_t _queue, clobj_t _mem,
});
}

#if PYOPENCL_CL_VERSION >= 0x1020
error*
enqueue_fill_image(clobj_t *evt, clobj_t _queue, clobj_t mem,
const void *color, const size_t *_orig, size_t orig_l,
const size_t *_reg, size_t reg_l,
const clobj_t *_wait_for, uint32_t num_wait_for)
{
#if PYOPENCL_CL_VERSION >= 0x1020
// TODO debug color
auto queue = static_cast<command_queue*>(_queue);
auto img = static_cast<image*>(mem);
Expand All @@ -191,8 +191,10 @@ enqueue_fill_image(clobj_t *evt, clobj_t _queue, clobj_t mem,
pyopencl_call_guarded(clEnqueueFillImage, queue, img, color, orig,
reg, wait_for, event_out(evt));
});
}
#else
PYOPENCL_UNSUPPORTED(clEnqueueFillImage, "CL 1.1 and below")
#endif
}

// {{{ image transfers

Expand Down
6 changes: 4 additions & 2 deletions src/c_wrapper/kernel.cpp
Expand Up @@ -155,17 +155,19 @@ kernel__get_work_group_info(clobj_t _knl, cl_kernel_work_group_info param,
});
}

#if PYOPENCL_CL_VERSION >= 0x1020
error*
kernel__get_arg_info(clobj_t _knl, cl_uint idx, cl_kernel_arg_info param,
generic_info *out)
{
#if PYOPENCL_CL_VERSION >= 0x1020
auto knl = static_cast<kernel*>(_knl);
return c_handle_error([&] {
*out = knl->get_arg_info(idx, param);
});
}
#else
PYOPENCL_UNSUPPORTED(clKernelGetArgInfo, "CL 1.1 and below")
#endif
}

error*
enqueue_nd_range_kernel(clobj_t *evt, clobj_t _queue, clobj_t _knl,
Expand Down
6 changes: 4 additions & 2 deletions src/c_wrapper/platform.cpp
Expand Up @@ -95,13 +95,15 @@ platform__get_devices(clobj_t _plat, clobj_t **_devices,
});
}

#if PYOPENCL_CL_VERSION >= 0x1020
error*
platform__unload_compiler(clobj_t plat)
{
#if PYOPENCL_CL_VERSION >= 0x1020
return c_handle_error([&] {
pyopencl_call_guarded(clUnloadPlatformCompiler,
static_cast<platform*>(plat));
});
}
#else
PYOPENCL_UNSUPPORTED(clUnloadPlatformCompiler, "CL 1.1 and below")
#endif
}
14 changes: 12 additions & 2 deletions src/c_wrapper/program.cpp
Expand Up @@ -189,37 +189,45 @@ program__get_build_info(clobj_t _prog, clobj_t _dev,
});
}

#if PYOPENCL_CL_VERSION >= 0x1020
error*
program__create_with_builtin_kernels(clobj_t *_prg, clobj_t _ctx,
const clobj_t *_devs, uint32_t num_devs,
const char *names)
{
#if PYOPENCL_CL_VERSION >= 0x1020
const auto devs = buf_from_class<device>(_devs, num_devs);
auto ctx = static_cast<context*>(_ctx);
return c_handle_error([&] {
auto prg = pyopencl_call_guarded(clCreateProgramWithBuiltInKernels,
ctx, devs, names);
*_prg = new_program(prg);
});
#else
PYOPENCL_UNSUPPORTED(clCreateProgramWithBuiltInKernels, "CL 1.1 and below")
#endif
}

error*
program__compile(clobj_t _prg, const char *opts, const clobj_t *_devs,
size_t num_devs, const clobj_t *_prgs,
const char *const *names, size_t num_hdrs)
{
#if PYOPENCL_CL_VERSION >= 0x1020
auto prg = static_cast<program*>(_prg);
return c_handle_error([&] {
prg->compile(opts, _devs, num_devs, _prgs, names, num_hdrs);
});
#else
PYOPENCL_UNSUPPORTED(clCompileProgram, "CL 1.1 and below")
#endif
}

error*
program__link(clobj_t *_prg, clobj_t _ctx, const clobj_t *_prgs,
size_t num_prgs, const char *opts, const clobj_t *_devs,
size_t num_devs)
{
#if PYOPENCL_CL_VERSION >= 0x1020
const auto devs = buf_from_class<device>(_devs, num_devs);
const auto prgs = buf_from_class<program>(_prgs, num_prgs);
auto ctx = static_cast<context*>(_ctx);
Expand All @@ -228,8 +236,10 @@ program__link(clobj_t *_prg, clobj_t _ctx, const clobj_t *_prgs,
prgs, nullptr, nullptr);
*_prg = new_program(prg);
});
}
#else
PYOPENCL_UNSUPPORTED(clLinkProgram, "CL 1.1 and below")
#endif
}

error*
program__all_kernels(clobj_t _prg, clobj_t **_knl, uint32_t *size)
Expand Down

0 comments on commit 4bb4089

Please sign in to comment.