Results 1 to 6 of 6

Thread: clCreatePipe segfault

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    6

    clCreatePipe segfault

    Code :
    #include <iostream>
    #define CL_TARGET_OPENCL_VERSION 220
    #include <CL/cl.h>
     
    int main(int argc, char* argv[])
    {
        cl_platform_id platform;
        clGetPlatformIDs(1, &platform, nullptr);
     
        cl_device_id devices[2];
        clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &devices[0], nullptr);
        clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &devices[1], nullptr);
        auto context = clCreateContext(nullptr, 2, devices, nullptr, nullptr, nullptr); 
     
        auto pipe = clCreatePipe(context, 0, sizeof(float), 256, nullptr, nullptr);
    }

    Looks like normal code but segfaults.

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    253
    Did you make sure your platform & device support pipes before calling that API? Maybe it's an OpenCL 1.2 device, which doesn't support pipes.

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    6
    Quote Originally Posted by Dithermaster View Post
    Did you make sure your platform & device support pipes before calling that API? Maybe it's an OpenCL 1.2 device, which doesn't support pipes.
    Code :
    #include <iostream>
    #define CL_TARGET_OPENCL_VERSION 220
    #include <CL/cl.h>
     
    int main(int argc, char* argv[])
    {
        cl_platform_id platform;
        clGetPlatformIDs(1, &platform, nullptr);
     
        cl_device_id devices[2];
        clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &devices[0], nullptr);
        clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &devices[1], nullptr);
        auto context = clCreateContext(nullptr, 2, devices, nullptr, nullptr, nullptr);
     
        char version[0xff];
        clGetDeviceInfo(devices[0], CL_DEVICE_VERSION, sizeof(version), version, nullptr);
        std::cout << version << std::endl;
        clGetDeviceInfo(devices[1], CL_DEVICE_VERSION, sizeof(version), version, nullptr);
        std::cout << version << std::endl;
     
        auto pipe = clCreatePipe(context, 0, sizeof(float), 256, nullptr, nullptr);
    }

    OpenCL 2.1 NEO
    OpenCL 2.1 (Build 716)
    Segmentation fault

    Btw, clCreatePipe for a context with one device is ok.
    Last edited by OmegaDoom; 09-25-2018 at 12:37 AM.

  4. #4
    Junior Member
    Join Date
    Sep 2018
    Posts
    6
    Interesting. My laptop has 3 platforms.

    Code :
    Platform count = 3
    ++++++++++++++++++platform+++++++++++++++++++
    PLATFORM_NAME = Intel(R) OpenCL
    PLATFORM_PROFILE = FULL_PROFILE
    PLATFORM_VERSION = OpenCL 2.1 
    PLATFORM_VENDOR = Intel(R) Corporation
    PLATFORM_EXTENSIONS = cl_intel_dx9_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_d3d11_sharing cl_khr_depth_images cl_khr_dx9_media_sharing cl_khr_fp64 cl_khr_gl_sharing cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_spir
    Device count = 2
    =============device=============
    DEVICE TYPE =  CL_DEVICE_TYPE_GPU
    MAX_GROUP_SIZE = 256
    LOCAL_MEM_SIZE = 65536
    MAX_COMPUTE_UNITS = 24
    MAX_WORK_ITEM_DIMENSIONS = 3
    dim[0] = 256 dim[1] = 256 dim[2] = 256 
    =============device=============
    DEVICE TYPE =  CL_DEVICE_TYPE_CPU
    MAX_GROUP_SIZE = 8192
    LOCAL_MEM_SIZE = 32768
    MAX_COMPUTE_UNITS = 8
    MAX_WORK_ITEM_DIMENSIONS = 3
    dim[0] = 8192 dim[1] = 8192 dim[2] = 8192 
    ++++++++++++++++++platform+++++++++++++++++++
    PLATFORM_NAME = Intel(R) OpenCL
    PLATFORM_PROFILE = FULL_PROFILE
    PLATFORM_VERSION = OpenCL 2.1 
    PLATFORM_VENDOR = Intel(R) Corporation
    PLATFORM_EXTENSIONS = cl_intel_dx9_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_d3d11_sharing cl_khr_depth_images cl_khr_dx9_media_sharing cl_khr_fp64 cl_khr_gl_sharing cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_spir
    Device count = 2
    =============device=============
    DEVICE TYPE =  CL_DEVICE_TYPE_GPU
    MAX_GROUP_SIZE = 256
    LOCAL_MEM_SIZE = 65536
    MAX_COMPUTE_UNITS = 24
    MAX_WORK_ITEM_DIMENSIONS = 3
    dim[0] = 256 dim[1] = 256 dim[2] = 256 
    =============device=============
    DEVICE TYPE =  CL_DEVICE_TYPE_CPU
    MAX_GROUP_SIZE = 8192
    LOCAL_MEM_SIZE = 32768
    MAX_COMPUTE_UNITS = 8
    MAX_WORK_ITEM_DIMENSIONS = 3
    dim[0] = 8192 dim[1] = 8192 dim[2] = 8192 
    ++++++++++++++++++platform+++++++++++++++++++
    PLATFORM_NAME = NVIDIA CUDA
    PLATFORM_PROFILE = FULL_PROFILE
    PLATFORM_VERSION = OpenCL 1.2 CUDA 10.0.150
    PLATFORM_VENDOR = NVIDIA Corporation
    PLATFORM_EXTENSIONS = 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_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_nv_create_buffer
    Device count = 1
    =============device=============
    DEVICE TYPE =  CL_DEVICE_TYPE_GPU
    MAX_GROUP_SIZE = 1024
    LOCAL_MEM_SIZE = 49152
    MAX_COMPUTE_UNITS = 4
    MAX_WORK_ITEM_DIMENSIONS = 3
    dim[0] = 1024 dim[1] = 1024 dim[2] = 64

    First and second platforms are identical. I don't understand how it is possible. I can't create a pipe for a context which has two devices from first or second platform.
    But if I combine devices from first and second platforms then clCreatePipe does't segfault! This is weird. Also can't create a context with devices from intel and nvidia platforms but that more or less makes sense.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Posts
    6
    This works.

    Code :
    #include <iostream>
    #define CL_TARGET_OPENCL_VERSION 220
    #include <CL/cl.h>
     
    int main(int argc, char* argv[])
    {
        cl_platform_id platforms[3];
        clGetPlatformIDs(3, platforms, nullptr);
     
        cl_device_id devices[2];
        clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 1, &devices[0], nullptr); // device from first platform
        clGetDeviceIDs(platforms[1], CL_DEVICE_TYPE_CPU, 1, &devices[1], nullptr);  // device from second platform
        auto context = clCreateContext(nullptr, 2, devices, nullptr, nullptr, nullptr);
        auto pipe = clCreatePipe(context, 0, sizeof(float), 256, nullptr, nullptr);
    }

    Weird.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Posts
    6
    it's working because of context is null. So no context for devices of different platforms.
    No pipe working?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean