Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCL codes are broken (plus compiler warnings). #5

Open
baryluk opened this issue Dec 13, 2018 · 0 comments
Open

OpenCL codes are broken (plus compiler warnings). #5

baryluk opened this issue Dec 13, 2018 · 0 comments

Comments

@baryluk
Copy link

baryluk commented Dec 13, 2018

Both Black-Scholes and Monte-Carlo benchmarks, fail the same way during execution. Here just first as a representative:

user@debian:~/FinanceBench/Black-Scholes/OpenCL$ make
g++ -O3 -I/usr/local/cuda-5.0/include  -lOpenCL -lm blackScholesAnalyticEngine.c -o blackScholesAnalyticEngine.exe
In file included from blackScholesAnalyticEngine.c:25:
blackScholesAnalyticEngineKernelsCpu.c:66:17: warning: floating constant truncated to zero [-Woverflow]
                 if (ax < DBL_MIN*16)
                 ^~
In file included from /usr/include/CL/cl.h:36,
                 from blackScholesAnalyticEngine.c:14:
/usr/include/CL/cl_version.h:34:104: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)")
                                                                                                        ^
blackScholesAnalyticEngine.c: In function ‘void cl_initialization()’:
blackScholesAnalyticEngine.c:97:74: warning: ‘_cl_command_queue* clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)’ is deprecated [-Wdeprecated-declarations]
  clCommandQue = clCreateCommandQueue(clGPUContext, device_id, 0, &errcode);
                                                                          ^
In file included from blackScholesAnalyticEngine.c:14:
/usr/include/CL/cl.h:1741:1: note: declared here
 clCreateCommandQueue(cl_context                     /* context */,
 ^~~~~~~~~~~~~~~~~~~~
blackScholesAnalyticEngine.c:97:74: warning: ‘_cl_command_queue* clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)’ is deprecated [-Wdeprecated-declarations]
  clCommandQue = clCreateCommandQueue(clGPUContext, device_id, 0, &errcode);
                                                                          ^
In file included from blackScholesAnalyticEngine.c:14:
/usr/include/CL/cl.h:1741:1: note: declared here
 clCreateCommandQueue(cl_context                     /* context */,
 ^~~~~~~~~~~~~~~~~~~~
user@debian:~/FinanceBench/Black-Scholes/OpenCL$ ls
blackScholesAnalyticEngine.c    blackScholesAnalyticEngineKernels.cl    blackScholesAnalyticEngineKernelsCpu.h  blackScholesAnalyticEngineStructs.h  errorFunctConsts.h
blackScholesAnalyticEngine.exe  blackScholesAnalyticEngineKernelsCpu.c  blackScholesAnalyticEngineKernels.h     blackScholesStructs.h                Makefile
user@debian:~/FinanceBench/Black-Scholes/OpenCL$ ./blackScholesAnalyticEngine.exe 
Number of options: 5000000

number of platforms is 1
platform name is Portable Computing Language
platform version is OpenCL 1.2 pocl 1.1 None+Asserts, LLVM 6.0.1, SPIR, SLEEF, DISTRO, POCL_DEBUG
Error getting device IDs
Error getting device name
Error in creating context
Error in creating command queue
Error in creating program
Error in building program
Segmentation fault
user@debian:~/FinanceBench/Black-Scholes/OpenCL$ sudo ./blackScholesAnalyticEngine.exe 
Number of options: 5000000

number of platforms is 2
platform name is Portable Computing Language
platform version is OpenCL 1.2 pocl 1.1 None+Asserts, LLVM 6.0.1, SPIR, SLEEF, DISTRO, POCL_DEBUG
Error getting device IDs
Error getting device name
Error in creating context
Error in creating command queue
Error in creating program
Error in building program
Segmentation fault
user@debian:~/FinanceBench/Black-Scholes/OpenCL$

(Notice also that, when run as root, two platforms are available (that is expected because my /dev/kfd has restrictive permissions), but it still selects the first platform (CPU), instead the AMD GPU OpenCL I have working).

clinfo:

$ clinfo 
Number of platforms                               2
  Platform Name                                   Portable Computing Language
  Platform Vendor                                 The pocl project
  Platform Version                                OpenCL 1.2 pocl 1.1 None+Asserts, LLVM 6.0.1, SPIR, SLEEF, DISTRO, POCL_DEBUG
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             POCL

  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (2679.0)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_event_callback 
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             AMD

  Platform Name                                   Portable Computing Language
Number of devices                                 1
  Device Name                                     pthread-AMD Ryzen Threadripper 2950X 16-Core Processor
  Device Vendor                                   AuthenticAMD
  Device Vendor ID                                0x1022
  Device Version                                  OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-znver1
  Driver Version                                  1.1
  Device OpenCL C Version                         OpenCL C 1.2 pocl
  Device Type                                     CPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               32
  Max clock frequency                             3500MHz
  Device Partition                                (core)
    Max number of sub-devices                     32
    Supported partition types                     equally, by counts
  Max work item dimensions                        3
  Max work item sizes                             4096x4096x4096
  Max work group size                             4096
  Preferred work group size multiple              8
  Preferred / native vector sizes                 
    char                                                16 / 16      
    short                                               16 / 16      
    int                                                  8 / 8       
    long                                                 4 / 4       
    half                                                 0 / 0        (n/a)
    float                                                8 / 8       
    double                                               4 / 4        (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
  Address bits                                    64, Little-Endian
  Global memory size                              65342607360 (60.86GiB)
  Error Correction support                        No
  Max memory allocation                           17179869184 (16GiB)
  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                        8388608 (8MiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            1073741824 pixels
    Max 1D or 2D image array size                 2048 images
    Max 2D image size                             32768x32768 pixels
    Max 3D image size                             2048x2048x2048 pixels
    Max number of read image args                 128
    Max number of write image args                128
  Local memory type                               Global
  Local memory size                               4194304 (4MiB)
  Max number of constant args                     8
  Max constant buffer size                        4194304 (4MiB)
  Max size of kernel argument                     1024
  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
    SPIR versions                                 1.2
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                
  Device Extensions                               cl_khr_byte_addressable_store 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_3d_image_writes cl_khr_spir cl_khr_fp64 cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp64

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 1
  Device Name                                     gfx803
  Device Vendor                                   Advanced Micro Devices, Inc.
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 1.2 
  Driver Version                                  2679.0 (HSA1.1,LC)
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Type                                     GPU
  Device Board Name (AMD)                         Fiji [Radeon R9 FURY / NANO Series]
  Device Topology (AMD)                           PCI-E, 0a:00.0
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               64
  SIMD per compute unit (AMD)                     4
  SIMD width (AMD)                                16
  SIMD instruction width (AMD)                    1
  Max clock frequency                             1050MHz
  Graphics IP (AMD)                               8.3
  Device Partition                                (core)
    Max number of sub-devices                     64
    Supported partition types                     None
  Max work item dimensions                        3
  Max work item sizes                             1024x1024x1024
  Max work group size                             256
  Preferred work group size (AMD)                 256
  Max work group size (AMD)                       1024
  Preferred work group size multiple              64
  Wavefront width (AMD)                           64
  Preferred / native vector sizes                 
    char                                                 4 / 4       
    short                                                2 / 2       
    int                                                  1 / 1       
    long                                                 1 / 1       
    half                                                 1 / 1        (cl_khr_fp16)
    float                                                1 / 1       
    double                                               1 / 1        (cl_khr_fp64)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     No
    Infinity and NANs                             No
    Round to nearest                              No
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
  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         (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
  Address bits                                    64, Little-Endian
  Global memory size                              4294967296 (4GiB)
  Global free memory (AMD)                        4192256 (3.998GiB)
  Global memory channels (AMD)                    16
  Global memory banks per channel (AMD)           4
  Global memory bank width (AMD)                  256 bytes
  Error Correction support                        No
  Max memory allocation                           3650722201 (3.4GiB)
  Unified memory for Host and Device              No
  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                        16384 (16KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             29440
    Max size for 1D images from buffer            65536 pixels
    Max 1D or 2D image array size                 2048 images
    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)
  Local memory syze per CU (AMD)                  65536 (64KiB)
  Local memory banks (AMD)                        32
  Max number of constant args                     8
  Max constant buffer size                        3650722201 (3.4GiB)
  Preferred constant buffer size (AMD)            16384 (16KiB)
  Max size of kernel argument                     1024
  Queue properties                                
    Out-of-order execution                        No
    Profiling                                     Yes
  Prefer user sync for interop                    Yes
  Number of P2P devices (AMD)                     0
  P2P devices (AMD)                               
  Profiling timer resolution                      1ns
  Profiling timer offset since Epoch (AMD)        0ns (Thu Jan  1 00:00:00 1970)
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Thread trace supported (AMD)                  No
    Number of async queues (AMD)                  8
    Max real-time compute queues (AMD)            8
    Max real-time compute units (AMD)             64
  printf() buffer size                            4194304 (4MiB)
  Built-in kernels                                
  Device Extensions                               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_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_amd_device_attribute_query cl_amd_media_ops cl_amd_media_ops2 cl_khr_subgroups cl_khr_depth_images cl_amd_copy_buffer_p2p cl_amd_assembly_program 

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  No platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   No platform
  clCreateContext(NULL, ...) [default]            No platform
  clCreateContext(NULL, ...) [other]              Success [POCL]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-AMD Ryzen Threadripper 2950X 16-Core Processor
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-AMD Ryzen Threadripper 2950X 16-Core Processor
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-AMD Ryzen Threadripper 2950X 16-Core Processor
user@debian:~/FinanceBench/Black-Scholes/OpenCL$ 

libraries:

$ dpkg -l | egrep -i 'ocl|opencl'
ii  clinfo                                                      2.2.18.03.26-1                          amd64        Query OpenCL system information
ii  libpocl-dev                                                 1.1-7                                   amd64        development files for the pocl library
ii  libpocl2:amd64                                              1.1-7                                   amd64        Portable Computing Language library
ii  libpocl2-common                                             1.1-7                                   all          common files for the pocl library
ii  ocl-icd-libopencl1:amd64                                    2.2.12-1                                amd64        Generic OpenCL ICD Loader
ii  ocl-icd-libopencl1:i386                                     2.2.12-1                                i386         Generic OpenCL ICD Loader
ii  ocl-icd-opencl-dev:amd64                                    2.2.12-1                                amd64        OpenCL development files
ii  opencl-c-headers                                            2.2~2018.05.14-gde26592-1               all          OpenCL (Open Computing Language) C header files
ii  pocl-opencl-icd:amd64                                       1.1-7                                   amd64        pocl ICD
ii  rocm-clang-ocl                                              0.3.0-7997136                           amd64        OpenCL compilation with clang compiler.
ii  rocm-opencl                                                 1.2.0-2018111340                        amd64        OpenCL/ROCm
ii  rocm-opencl-dev                                             1.2.0-2018111340                        amd64        OpenCL/ROCm
$

gcc 8.2.0, amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant