Closed McCulloughRT closed 7 years ago
Hi there. It seems like you are using an old version of the compiler, as the typename int32
is not a valid anymore -- instead you should use i32
.
After changing this, your example works on my version of the compiler, so you probably just try updating the compiler :)
I suspect the problem is unrelated to array slicing. Are you using macOS? It looks like an error I have seen before on that platform. The issue is that Futhark (by default) uses the first available OpenCL device, which on macOS is the CPU. While Futhark interrogates the chosen device about limitations (such as the maximum workgroup size) and adapts as necessary, the macOS CPU device seems to misreport its capabilities, so the first kernel launch ends up failing. I don't have access to a Mac, so I can't debug it well enough to figure out what's going on.
The workaround is simple: specify another OpenCL device or platform using the -d
or -p
options on the generated executable. For example, if you have an NVIDIA GeForce card that you would like to use, you could pass either -p NVIDIA
or -d GeForce
. You'll have to figure out yourself which other OpenCL platforms and devices are available, and what they call themselves. I usually use the clinfo tool for this purpose.
In the future, if you suspect that your program is wrong, it's probably a good idea to run it with futhark-c
and see if you get a similar error. The OpenCL compiler is still much more fragile and sensitive to its runtime environment, while futhark-c
should be able to handle anything.
Thanks to both of you!
Rasmus, I inadvertantly typed int32 in the code block above, generally I'm using i32 as recommended, but that is some interesting history on the compiler!
Athas, it looks like you're correct. I am compiling on a MacBook pro, and when I compile with futhark-c everything works as expected! Thank you! Is there anything I can do or provide to help in debugging the OpenCL compiler issue?
If you can run clinfo
and post the output here, that would be a start. Maybe I'm misunderstanding what the device is telling Futhark.
Here is the output of clinfo: `Number of platforms 1 Platform Name Apple Platform Vendor Apple Platform Version OpenCL 1.2 (Jan 4 2017 22:35:59) Platform Profile FULL_PROFILE Platform Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event
Platform Name Apple
Number of devices 3
Device Name Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Device Vendor Intel
Device Vendor ID 0xffffffff
Device Version OpenCL 1.2
Driver Version 1.1
Device OpenCL C Version OpenCL C 1.2
Device Type CPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 8
Max clock frequency 2500MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 1024x1x1
Max work group size 1024
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 1
Preferred / native vector sizes
char 16 / 16
short 8 / 8
int 4 / 4
long 2 / 2
half 0 / 0 (n/a)
float 4 / 4
double 2 / 2 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 17179869184 (16GiB)
Error Correction support No
Max memory allocation 4294967296 (4GiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type Read/Write
Global Memory cache size 64
Global Memory cache line 6291456 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 1 bytes
Pitch alignment for 2D image buffers 1 bytes
Max 2D image size 8192x8192 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Global
Local memory size 32768 (32KiB)
Max constant buffer size 65536 (64KiB)
Max number of constant args 8
Max size of kernel argument 4096 (4KiB)
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_APPLE_fp64_basic_ops cl_APPLE_fixed_alpha_channel_orders cl_APPLE_biased_fixed_point_image_formats cl_APPLE_command_queue_priority
Device Name Iris Pro
Device Vendor Intel
Device Vendor ID 0x1024500
Device Version OpenCL 1.2
Driver Version 1.2(Jan 4 2017 22:48:41)
Device OpenCL C Version OpenCL C 1.2
Device Type GPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 40
Max clock frequency 1200MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 512x512x512
Max work group size 512
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 32
Preferred / native vector sizes
char 1 / 1
short 1 / 1
int 1 / 1
long 1 / 1
half 0 / 0 (n/a)
float 1 / 1
double 0 / 0 (n/a)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (n/a)
Address bits 64, Little-Endian
Global memory size 1610612736 (1.5GiB)
Error Correction support No
Max memory allocation 402653184 (384MiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type None
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 25165824 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 4 bytes
Pitch alignment for 2D image buffers 32 bytes
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Local
Local memory size 65536 (64KiB)
Max constant buffer size 65536 (64KiB)
Max number of constant args 8
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 80ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_image2d_from_buffer cl_khr_gl_depth_images cl_khr_depth_images cl_khr_3d_image_writes
Device Name AMD Radeon R9 M370X Compute Engine
Device Vendor AMD
Device Vendor ID 0x1021c00
Device Version OpenCL 1.2
Driver Version 1.2 (Jan 10 2017 22:25:08)
Device OpenCL C Version OpenCL C 1.2
Device Type GPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 10
Max clock frequency 800MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 64
Preferred / native vector sizes
char 4 / 4
short 2 / 2
int 1 / 1
long 1 / 1
half 0 / 0 (n/a)
float 1 / 1
double 1 / 1 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 32, Little-Endian
Global memory size 2147483648 (2GiB)
Error Correction support No
Max memory allocation 536870912 (512MiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 32768 bits (4096 bytes)
Global Memory cache type None
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 256 bytes
Pitch alignment for 2D image buffers 256 bytes
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Local
Local memory size 32768 (32KiB)
Max constant buffer size 65536 (64KiB)
Max number of constant args 8
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 37ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
printf() buffer size 134217728 (128MiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_image2d_from_buffer cl_khr_depth_images cl_APPLE_command_queue_priority cl_APPLE_command_queue_select_compute_units cl_khr_fp64
NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Apple clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [P0] clCreateContext(NULL, ...) [default] Success [P0] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) Success (1) Platform Name Apple Device Name Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (2) Platform Name Apple Device Name Iris Pro Device Name AMD Radeon R9 M370X Compute Engine clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) <checkNullCtxFromType:2350: create context from type CL_DEVICE_TYPE_CUSTOM : error -30> clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (3) Platform Name Apple Device Name Iris Pro Device Name AMD Radeon R9 M370X Compute Engine Device Name Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz`
I have no idea why Futhark fails when running on the CPU device - it seems to report Max work group size: 1024
, which is not less than what Futhark will use. I suspect there's a bug in Apple's CPU driver. I will take a closer look when I manage to get physical access to a Mac one day.
Anyway, your workaround would be passing -d Radeon
or -d Iris
to the executable generated by Futhark, depending on whether you want to use the AMD GPU or the integrated Intel GPU.
I'm just getting started with futhark, and so I have a strong suspicion I'm simply doing something wrong, but whenever I attempt to slice an array using the a[i:j:s] syntax I end up with a runtime error.
Even with toy examples like:
fun main():[]int32 = let arr = [1,2,3,4] in arr[::-1]
It compiles just fine, but at runtime produces the following OpenCL error:
./slice: slice.c:1484: OpenCL call clEnqueueNDRangeKernel(fut_cl_queue, kernel_copy_162, 1, NULL, global_work_sizze_170, local_work_sizze_174, 0, NULL, NULL) failed with error code -54 (Invalid work group size)
Can anyone provide some guidance? -Thanks