720
710
case CL_DEVICE_PREFERRED_INTEROP_USER_SYNC: DEV_GET_INT_INF(cl_bool);
721
711
case CL_DEVICE_PRINTF_BUFFER_SIZE: DEV_GET_INT_INF(cl_bool);
715
// types of AMD dev attrs divined from
716
// https://www.khronos.org/registry/cl/api/1.2/cl.hpp
717
#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD
718
case CL_DEVICE_PROFILING_TIMER_OFFSET_AMD: DEV_GET_INT_INF(cl_ulong);
721
#ifdef CL_DEVICE_TOPOLOGY_AMD
722
case CL_DEVICE_TOPOLOGY_AMD:
725
#ifdef CL_DEVICE_BOARD_NAME_AMD
726
case CL_DEVICE_BOARD_NAME_AMD: ;
727
PYOPENCL_GET_STR_INFO(Device, m_device, param_name);
729
#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD
730
case CL_DEVICE_GLOBAL_FREE_MEMORY_AMD:
732
std::vector<size_t> result;
733
PYOPENCL_GET_VEC_INFO(Device, m_device, param_name, result);
734
PYOPENCL_RETURN_VECTOR(size_t, result);
737
#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD
738
case CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD: DEV_GET_INT_INF(cl_uint);
740
#ifdef CL_DEVICE_SIMD_WIDTH_AMD
741
case CL_DEVICE_SIMD_WIDTH_AMD: DEV_GET_INT_INF(cl_uint);
743
#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD
744
case CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD: DEV_GET_INT_INF(cl_uint);
746
#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD
747
case CL_DEVICE_WAVEFRONT_WIDTH_AMD: DEV_GET_INT_INF(cl_uint);
749
#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD
750
case CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD: DEV_GET_INT_INF(cl_uint);
752
#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD
753
case CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD: DEV_GET_INT_INF(cl_uint);
755
#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
756
case CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD: DEV_GET_INT_INF(cl_uint);
758
#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
759
case CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD: DEV_GET_INT_INF(cl_uint);
761
#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD
762
case CL_DEVICE_LOCAL_MEM_BANKS_AMD: DEV_GET_INT_INF(cl_uint);
766
#ifdef CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT
767
case CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT: DEV_GET_INT_INF(cl_uint);
725
771
throw error("Device.get_info", CL_INVALID_VALUE);
1355
#if PYOPENCL_CL_VERSION >= 0x1020
1325
event *enqueue_marker(command_queue &cq,
1357
event *enqueue_marker_with_wait_list(command_queue &cq,
1326
1358
py::object py_wait_for)
1328
1360
PYOPENCL_PARSE_WAIT_FOR;
1331
#if PYOPENCL_CL_VERSION >= 0x1020
1332
1363
PYOPENCL_CALL_GUARDED(clEnqueueMarkerWithWaitList, (
1333
1364
cq.data(), PYOPENCL_WAITLIST_ARGS, &evt));
1335
if (num_events_in_wait_list)
1337
PYOPENCL_CALL_GUARDED(clEnqueueWaitForEvents, (
1338
cq.data(), PYOPENCL_WAITLIST_ARGS));
1340
PYOPENCL_CALL_GUARDED(clEnqueueMarker, (
1344
1366
PYOPENCL_RETURN_NEW_EVENT(evt);
1352
event *enqueue_barrier(command_queue &cq,
1370
event *enqueue_barrier_with_wait_list(command_queue &cq,
1353
1371
py::object py_wait_for)
1355
1373
PYOPENCL_PARSE_WAIT_FOR;
1358
#if PYOPENCL_CL_VERSION >= 0x1020
1359
1376
PYOPENCL_CALL_GUARDED(clEnqueueBarrierWithWaitList,
1360
1377
(cq.data(), PYOPENCL_WAITLIST_ARGS, &evt));
1363
if (num_events_in_wait_list)
1365
PYOPENCL_CALL_GUARDED(clEnqueueWaitForEvents, (
1366
cq.data(), PYOPENCL_WAITLIST_ARGS));
1369
PYOPENCL_CALL_GUARDED(clEnqueueBarrier, (cq.data()));
1379
PYOPENCL_RETURN_NEW_EVENT(evt);
1384
// {{{ used internally for pre-OpenCL-1.2 contexts
1387
event *enqueue_marker(command_queue &cq)
1371
1391
PYOPENCL_CALL_GUARDED(clEnqueueMarker, (
1372
1392
cq.data(), &evt));
1375
1394
PYOPENCL_RETURN_NEW_EVENT(evt);
1382
1398
void enqueue_wait_for_events(command_queue &cq, py::object py_events)
1384
PYOPENCL_DEPRECATED("enqueue_wait_for_events", "2013.1", );
1386
1400
cl_uint num_events = 0;
1387
1401
std::vector<cl_event> event_list(len(py_events));
1394
1408
cq.data(), num_events, event_list.empty( ) ? NULL : &event_list.front()));
1412
void enqueue_barrier(command_queue &cq)
1414
PYOPENCL_CALL_GUARDED(clEnqueueBarrier, (cq.data()));
1400
1420
#if PYOPENCL_CL_VERSION >= 0x1010
1795
1810
PYOPENCL_RETRY_IF_MEM_ERROR(
1796
PYOPENCL_CALL_GUARDED(clEnqueueReadBuffer, (
1811
PYOPENCL_CALL_GUARDED_THREADED(clEnqueueReadBuffer, (
1799
1814
PYOPENCL_CAST_BOOL(is_blocking),
1828
1843
PYOPENCL_RETRY_IF_MEM_ERROR(
1829
PYOPENCL_CALL_GUARDED(clEnqueueWriteBuffer, (
1844
PYOPENCL_CALL_GUARDED_THREADED(clEnqueueWriteBuffer, (
1832
1847
PYOPENCL_CAST_BOOL(is_blocking),
1913
1928
PYOPENCL_RETRY_IF_MEM_ERROR(
1914
PYOPENCL_CALL_GUARDED(clEnqueueReadBufferRect, (
1929
PYOPENCL_CALL_GUARDED_THREADED(clEnqueueReadBufferRect, (
1917
1932
PYOPENCL_CAST_BOOL(is_blocking),
1959
1974
PYOPENCL_RETRY_IF_MEM_ERROR(
1960
PYOPENCL_CALL_GUARDED(clEnqueueWriteBufferRect, (
1975
PYOPENCL_CALL_GUARDED_THREADED(clEnqueueWriteBufferRect, (
1963
1978
PYOPENCL_CAST_BOOL(is_blocking),
2618
2633
memory_object_holder &buf,
2619
2634
cl_map_flags flags,
2621
py::object py_shape, py::object dtype, py::object order_py,
2636
py::object py_shape, py::object dtype,
2637
py::object py_order, py::object py_strides,
2622
2638
py::object py_wait_for,
2623
2639
bool is_blocking
2640
2656
PYOPENCL_RETRY_IF_MEM_ERROR(
2658
Py_BEGIN_ALLOW_THREADS
2642
2659
mapped = clEnqueueMapBuffer(
2643
2660
cq.data(), buf.data(),
2644
2661
PYOPENCL_CAST_BOOL(is_blocking), flags,
2645
2662
offset, size_in_bytes,
2646
2663
PYOPENCL_WAITLIST_ARGS, &evt,
2665
Py_END_ALLOW_THREADS
2648
2666
if (status_code != CL_SUCCESS)
2649
2667
throw pyopencl::error("clEnqueueMapBuffer", status_code);
2657
2675
result = py::handle<>(PyArray_NewFromDescr(
2658
2676
&PyArray_Type, tp_descr,
2659
shape.size(), shape.empty( ) ? NULL : &shape.front(), /*strides*/ NULL,
2678
shape.empty() ? NULL : &shape.front(),
2679
strides.empty() ? NULL : &strides.front(),
2660
2680
mapped, ary_flags, /*obj*/NULL));
2662
2682
if (size_in_bytes != (npy_uintp) PyArray_NBYTES(result.get()))
2663
2683
throw pyopencl::error("enqueue_map_buffer", CL_INVALID_VALUE,
2664
"miscalculated numpy array size");
2684
"miscalculated numpy array size (not contiguous?)");
2666
2686
map = std::auto_ptr<memory_map>(new memory_map(cq, buf, mapped));
2691
2711
cl_map_flags flags,
2692
2712
py::object py_origin,
2693
2713
py::object py_region,
2694
py::object py_shape, py::object dtype, py::object order_py,
2714
py::object py_shape, py::object dtype,
2715
py::object py_order, py::object py_strides,
2695
2716
py::object py_wait_for,
2696
2717
bool is_blocking
2709
2730
PYOPENCL_RETRY_IF_MEM_ERROR(
2732
Py_BEGIN_ALLOW_THREADS
2711
2733
mapped = clEnqueueMapImage(
2712
2734
cq.data(), img.data(),
2713
2735
PYOPENCL_CAST_BOOL(is_blocking), flags,
2714
2736
origin, region, &row_pitch, &slice_pitch,
2715
2737
PYOPENCL_WAITLIST_ARGS, &evt,
2739
Py_END_ALLOW_THREADS
2717
2740
if (status_code != CL_SUCCESS)
2718
2741
throw pyopencl::error("clEnqueueMapImage", status_code);
2735
2758
py::handle<> result = py::handle<>(PyArray_NewFromDescr(
2736
2759
&PyArray_Type, tp_descr,
2737
shape.size(), shape.empty( ) ? NULL : &shape.front(), /*strides*/ NULL,
2761
shape.empty() ? NULL : &shape.front(),
2762
strides.empty() ? NULL : &strides.front(),
2738
2763
mapped, ary_flags, /*obj*/NULL));
2740
2765
py::handle<> map_py(handle_from_new_ptr(map.release()));
2770
2795
throw pyopencl::error("Sampler", status_code);
2798
sampler(cl_sampler samp, bool retain)
2802
PYOPENCL_CALL_GUARDED(clRetainSampler, (samp));
2775
2807
PYOPENCL_CALL_GUARDED_CLEANUP(clReleaseSampler, (m_sampler));
3829
3846
// {{{ deferred implementation bits
3831
inline py::object create_event_wrapper_from_int(intptr_t cl_event_as_int)
3833
return py::object(handle_from_new_ptr(new event((cl_event)cl_event_as_int, true)));
3836
3848
inline py::object create_mem_object_wrapper(cl_mem mem)
3838
3850
cl_mem_object_type mem_obj_type;