javaopenclgpujocl

Error CL_DEVICE_NOT_AVAILABLE in JOCL sampels


I need to use OpenCl with java So I have chosen JOCL when I wanted to try jocl samples ( http://www.jocl.org/samples/samples.html) I always find this error when compiling the samples.

for example the sample (JOCLSample_1_2_KernelArgs.java) shows this errors:

**Exception in thread "main" org.jocl.CLException: CL_DEVICE_NOT_AVAILABLE
at org.jocl.CL.checkResult(CL.java:686)
at org.jocl.CL.clCreateContext(CL.java:3803)
at org.jocl.JOCLSample_1_2_KernelArgs.defaultInitialization(JOCLSample_1_2_KernelArgs.java:177)
at org.jocl.JOCLSample_1_2_KernelArgs.main(JOCLSample_1_2_KernelArgs.java:42)**

I am sure that my drivers works well.

when I compile the sample JOCLDeviceQuery.java (which shows Queries and prints information about all available devices.)

This is the result:

Number of platforms: 4
Number of devices in platform Intel(R) OpenCL: 2
Number of devices in platform NVIDIA CUDA: 1
Number of devices in platform Experimental OpenCL 2.0 CPU Only Platform: 1
Number of devices in platform AMD Accelerated Parallel Processing: 1
--- Info for device        Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz: ---
CL_DEVICE_NAME:                    Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
CL_DEVICE_VENDOR:           Intel(R) Corporation
CL_DRIVER_VERSION:          5.0.0.57
CL_DEVICE_TYPE:             CL_DEVICE_TYPE_CPU
CL_DEVICE_MAX_COMPUTE_UNITS:        4
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
CL_DEVICE_MAX_WORK_ITEM_SIZES:      8192 / 8192 / 8192 
CL_DEVICE_MAX_WORK_GROUP_SIZE:      8192
CL_DEVICE_MAX_CLOCK_FREQUENCY:      1800 MHz
CL_DEVICE_ADDRESS_BITS:         64
CL_DEVICE_MAX_MEM_ALLOC_SIZE:       998 MByte
CL_DEVICE_GLOBAL_MEM_SIZE:      3995 MByte
CL_DEVICE_ERROR_CORRECTION_SUPPORT: no
CL_DEVICE_LOCAL_MEM_TYPE:       global
CL_DEVICE_LOCAL_MEM_SIZE:       32 KByte
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 128 KByte
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_PROFILING_ENABLE
CL_DEVICE_IMAGE_SUPPORT:        1
CL_DEVICE_MAX_READ_IMAGE_ARGS:      480
CL_DEVICE_MAX_WRITE_IMAGE_ARGS:     480
CL_DEVICE_SINGLE_FP_CONFIG:     CL_FP_DENORM CL_FP_INF_NAN CL_FP_ROUND_TO_NEAREST 
CL_DEVICE_2D_MAX_WIDTH          16384
CL_DEVICE_2D_MAX_HEIGHT         16384
CL_DEVICE_3D_MAX_WIDTH          2048
CL_DEVICE_3D_MAX_HEIGHT         2048
CL_DEVICE_3D_MAX_DEPTH          2048
CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>    CHAR 1, SHORT 1, INT 1, LONG 1, FLOAT 1, DOUBLE 1


--- Info for device Intel(R) HD Graphics 4000: ---
CL_DEVICE_NAME:             Intel(R) HD Graphics 4000
CL_DEVICE_VENDOR:           Intel(R) Corporation
CL_DRIVER_VERSION:          9.17.10.2828
CL_DEVICE_TYPE:             CL_DEVICE_TYPE_GPU
CL_DEVICE_MAX_COMPUTE_UNITS:        16
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
CL_DEVICE_MAX_WORK_ITEM_SIZES:      512 / 512 / 512 
CL_DEVICE_MAX_WORK_GROUP_SIZE:      512
CL_DEVICE_MAX_CLOCK_FREQUENCY:      350 MHz
CL_DEVICE_ADDRESS_BITS:         64
CL_DEVICE_MAX_MEM_ALLOC_SIZE:       406 MByte
CL_DEVICE_GLOBAL_MEM_SIZE:      1624 MByte
CL_DEVICE_ERROR_CORRECTION_SUPPORT: no
CL_DEVICE_LOCAL_MEM_TYPE:       local
CL_DEVICE_LOCAL_MEM_SIZE:       64 KByte
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 64 KByte
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_PROFILING_ENABLE
CL_DEVICE_IMAGE_SUPPORT:        1
CL_DEVICE_MAX_READ_IMAGE_ARGS:      128
CL_DEVICE_MAX_WRITE_IMAGE_ARGS:     8
CL_DEVICE_SINGLE_FP_CONFIG:     CL_FP_INF_NAN CL_FP_ROUND_TO_NEAREST CL_FP_ROUND_TO_ZERO CL_FP_ROUND_TO_INF 
CL_DEVICE_2D_MAX_WIDTH          16384
CL_DEVICE_2D_MAX_HEIGHT         16384
CL_DEVICE_3D_MAX_WIDTH          2048
CL_DEVICE_3D_MAX_HEIGHT         2048
CL_DEVICE_3D_MAX_DEPTH          2048
CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>    CHAR 1, SHORT 1, INT 1, LONG 1, FLOAT 1, DOUBLE 0


--- Info for device GeForce GT 630M: ---
CL_DEVICE_NAME:             GeForce GT 630M
CL_DEVICE_VENDOR:           NVIDIA Corporation
CL_DRIVER_VERSION:          352.86
CL_DEVICE_TYPE:             CL_DEVICE_TYPE_GPU
CL_DEVICE_MAX_COMPUTE_UNITS:        2
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
CL_DEVICE_MAX_WORK_ITEM_SIZES:      1024 / 1024 / 64 
CL_DEVICE_MAX_WORK_GROUP_SIZE:      1024
CL_DEVICE_MAX_CLOCK_FREQUENCY:      1600 MHz
CL_DEVICE_ADDRESS_BITS:         64
CL_DEVICE_MAX_MEM_ALLOC_SIZE:       256 MByte
CL_DEVICE_GLOBAL_MEM_SIZE:      1024 MByte
CL_DEVICE_ERROR_CORRECTION_SUPPORT: no
CL_DEVICE_LOCAL_MEM_TYPE:       local
CL_DEVICE_LOCAL_MEM_SIZE:       48 KByte
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 64 KByte
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_PROFILING_ENABLE
CL_DEVICE_IMAGE_SUPPORT:        1
CL_DEVICE_MAX_READ_IMAGE_ARGS:      128
CL_DEVICE_MAX_WRITE_IMAGE_ARGS:     8
CL_DEVICE_SINGLE_FP_CONFIG:     CL_FP_DENORM CL_FP_INF_NAN CL_FP_ROUND_TO_NEAREST CL_FP_ROUND_TO_ZERO CL_FP_ROUND_TO_INF CL_FP_FMA CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT 
CL_DEVICE_2D_MAX_WIDTH          16384
CL_DEVICE_2D_MAX_HEIGHT         16384
CL_DEVICE_3D_MAX_WIDTH          2048
CL_DEVICE_3D_MAX_HEIGHT         2048
CL_DEVICE_3D_MAX_DEPTH          2048
CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>    CHAR 1, SHORT 1, INT 1, LONG 1, FLOAT 1, DOUBLE 1


--- Info for device        Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz: ---
CL_DEVICE_NAME:                    Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
CL_DEVICE_VENDOR:           Intel(R) Corporation
CL_DRIVER_VERSION:          6.0.0.1049
CL_DEVICE_TYPE:             CL_DEVICE_TYPE_CPU
CL_DEVICE_MAX_COMPUTE_UNITS:        4
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
CL_DEVICE_MAX_WORK_ITEM_SIZES:      8192 / 8192 / 8192 
CL_DEVICE_MAX_WORK_GROUP_SIZE:      8192
CL_DEVICE_MAX_CLOCK_FREQUENCY:      1800 MHz
CL_DEVICE_ADDRESS_BITS:         64
CL_DEVICE_MAX_MEM_ALLOC_SIZE:       998 MByte
CL_DEVICE_GLOBAL_MEM_SIZE:      3995 MByte
CL_DEVICE_ERROR_CORRECTION_SUPPORT: no
CL_DEVICE_LOCAL_MEM_TYPE:       global
CL_DEVICE_LOCAL_MEM_SIZE:       32 KByte
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 128 KByte
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
CL_DEVICE_QUEUE_PROPERTIES:     CL_QUEUE_PROFILING_ENABLE
CL_DEVICE_IMAGE_SUPPORT:        1
CL_DEVICE_MAX_READ_IMAGE_ARGS:      480
CL_DEVICE_MAX_WRITE_IMAGE_ARGS:     480
CL_DEVICE_SINGLE_FP_CONFIG:     CL_FP_DENORM CL_FP_INF_NAN CL_FP_ROUND_TO_NEAREST 
CL_DEVICE_2D_MAX_WIDTH          16384
CL_DEVICE_2D_MAX_HEIGHT         16384
CL_DEVICE_3D_MAX_WIDTH          2048
CL_DEVICE_3D_MAX_HEIGHT         2048
CL_DEVICE_3D_MAX_DEPTH          2048
CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>    CHAR 1, SHORT 1, INT 1, LONG 1, FLOAT 1, DOUBLE 1


--- Info for device        Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz

what is the solution for my problem???????how can I compile jocl samples ???


Solution

  • Try changing the device type from CL_DEVICE_TYPE_ALL

    to CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_GPU

    In OpenCL, it's better not to mix device types

    see the example code

    public class JOCLSample_1_2_KernelArgs
    {
        // The platform, device type and device number that will be used
        private static final int platformIndex = 0;
        private static final long deviceType = CL_DEVICE_TYPE_ALL;
        ...