CNugteren / CLBlast

Tuned OpenCL BLAS
Apache License 2.0
1.05k stars 205 forks source link

make alltuner error #491

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi, I want to export a json to supply tuner variables for Adreno 640 devices.

I build CLBlast fine, but make alltuners fails when I follow documentation from: https://github.com/CNugteren/CLBlast/blob/master/doc/tuning.md

Here's the error;

LD_LIBRARY_PATH=/vendor/lib64:$PREFIX/lib make alltuners
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/bin/cmake": cannot locate symbol "_ZNKSt6__ndk14__fs10filesystem4path10__filenameEv" referenced by "/data/data/com.termux/files/usr/bin/cmake"...
make: *** [Makefile:3065: cmake_check_build_system] Error 1

I tried without including path to OpenCL library:

make alltuners
[  6%] Built target tuners_common_library
[  7%] Built target clblast_tuner_invert
[  9%] Built target clblast_tuner_copy_fast
[ 11%] Built target clblast_tuner_copy_pad
[ 13%] Built target clblast_tuner_xgemm
[ 15%] Built target clblast_tuner_xger
[ 17%] Built target clblast_tuner_transpose_pad
[ 19%] Built target clblast_tuner_xdot
[ 21%] Built target clblast_tuner_xaxpy
[ 23%] Built target clblast_tuner_transpose_fast
[ 91%] Built target clblast
[ 93%] Built target clblast_tuner_routine_xtrsv
[ 94%] Built target clblast_tuner_xgemm_direct
[ 95%] Built target clblast_tuner_xconvgemm
[ 98%] Built target clblast_tuner_routine_xgemm
[100%] Built target clblast_tuner_xgemv
* Options given/available:
    -platform 0 [=default]
    -device 0 [=default]
    -precision 32 (single) [=default]
    -m 1024 [=default]
    -n 1024 [=default]
    -alpha 2.00 [=default]
    -fraction 1.00 [=default]
    -runs 10 [=default]
    -max_l2_norm 0.00 [=default]

CLBlast: OpenCL error: clGetPlatformIDs: -1001
make[3]: *** [CMakeFiles/alltuners.dir/build.make:70: CMakeFiles/alltuners] Error 23
make[2]: *** [CMakeFiles/Makefile2:545: CMakeFiles/alltuners.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:552: CMakeFiles/alltuners.dir/rule] Error 2
make: *** [Makefile:377: alltuners] Error 2

Here's clinfo;

LD_LIBRARY_PATH=/system/vendor/lib64 clinfo
Number of platforms                               1
  Platform Name                                   QUALCOMM Snapdragon(TM)
  Platform Vendor                                 QUALCOMM
  Platform Version                                OpenCL 2.0 QUALCOMM build: commit #3dad7f8ed7 changeid #I593c16c433 Date: 10/01/21 Fri Local Branch:  Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.UM.9.1.R1.11.00.00.604.073
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             

  Platform Name                                   QUALCOMM Snapdragon(TM)
Number of devices                                 1
  Device Name                                     QUALCOMM Adreno(TM)
  Device Vendor                                   QUALCOMM
  Device Vendor ID                                0x5143
  Device Version                                  OpenCL 2.0 Adreno(TM) 640
  Driver Version                                  OpenCL 2.0 QUALCOMM build: commit #3dad7f8ed7 changeid #I593c16c433 Date: 10/01/21 Fri Local Branch:  Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.UM.9.1.R1.11.00.00.604.073 Compiler E031.37.12.01
  Device OpenCL C Version                         OpenCL C 2.0 Adreno(TM) 640
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               2
  Max clock frequency                             1MHz
  Device Partition                                (core)
    Max number of sub-devices                     1
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             1024x1024x1024
  Max work group size                             1024
  Preferred work group size multiple (kernel)     128
  Preferred / native vector sizes
    char                                                 1 / 1
    short                                                1 / 1
    int                                                  1 / 1
    long                                                 1 / 0
    half                                                 1 / 1        (cl_khr_fp16)
    float                                                1 / 1
    double                                               0 / 0        (n/a)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             Yes
    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                                 No
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (n/a)
  Address bits                                    64, Little-Endian
  Global memory size                              3911952384 (3.643GiB)
  Error Correction support                        No
  Max memory allocation                           977988096 (932.7MiB)
  Unified memory for Host and Device              Yes
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 Yes
    Fine-grained buffer sharing                   Yes
    Fine-grained system sharing                   No
    Atomics                                       Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Page size (QCOM)                                4096 bytes
  External memory padding (QCOM)                  0 bytes
  Preferred alignment for atomics
    SVM                                           128 bytes
    Global                                        0 bytes
    Local                                         0 bytes
  Max size for global variable                    65536 (64KiB)
  Preferred total size of global vars             1048576 (1024KiB)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        131072 (128KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            134217728 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   64 bytes
    Pitch alignment for 2D image buffers          64 pixels
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             16384x16384x2048 pixels
    Max number of read image args                 128
    Max number of write image args                64
    Max number of read/write image args           64
  Max number of pipe args                         16
  Max active pipe reservations                    7680
  Max pipe packet size                            1024
  Local memory type                               Local
  Local memory size                               32768 (32KiB)
  Max number of constant args                     8
  Max constant buffer size                        65536 (64KiB)
  Max size of kernel argument                     1024
  Queue properties (on host)
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Queue properties (on device)
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Preferred size                                655376 (640KiB)
    Max size                                      655376 (640KiB)
  Max queues on device                            1
  Max events on device                            1024
  Prefer user sync for interop                    No
  Profiling timer resolution                      1000ns
  Execution capabilities
    Run OpenCL kernels                            Yes
    Run native kernels                            No
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_3d_image_writes cl_img_egl_image cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_egl_event cl_khr_egl_image cl_khr_fp16 cl_khr_gl_sharing 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_image2d_from_buffer cl_khr_mipmap_image cl_khr_srgb_image_writes cl_khr_subgroups cl_qcom_create_buffer_from_image cl_qcom_ext_host_ptr cl_qcom_ion_host_ptr cl_qcom_perf_hint cl_qcom_other_image cl_qcom_subgroup_shuffle cl_qcom_vector_image_ops cl_qcom_extract_image_plane cl_qcom_android_native_buffer_host_ptr cl_qcom_protected_context cl_qcom_priority_hint cl_qcom_compressed_yuv_image_read cl_qcom_compressed_image cl_qcom_ext_host_ptr_iocoherent cl_qcom_accelerated_image_ops cl_qcom_ml_ops

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 [P0]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 QUALCOMM Snapdragon(TM)
    Device Name                                   QUALCOMM Adreno(TM)
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 QUALCOMM Snapdragon(TM)
    Device Name                                   QUALCOMM Adreno(TM)
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  Invalid device type for platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 QUALCOMM Snapdragon(TM)
    Device Name                                   QUALCOMM Adreno(TM)

Thank you.

alexfarseer commented 1 year ago

Try this:

export LD_LIBRARY_PATH=/system/vendor/lib64:$PREFIX/lib
make alltuners

If that does not work try switching the directories like this:

export LD_LIBRARY_PATH=$PREFIX/lib:/system/vendor/lib64
make alltuners
ghost commented 1 year ago

Try this:

export LD_LIBRARY_PATH=/system/vendor/lib64:$PREFIX/lib
make alltuners

Thank you for your response. Unfortunately, no success.

~/CLBlast/build (master) [2]> export LD_LIBRARY_PATH=/system/vendor/lib64:$PREFIX/lib
u0_a1282@localhost ~/CLBlast/build (master)> make alltuners
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/bin/cmake": cannot locate symbol "_ZNKSt6__ndk14__fs10filesystem4path10__filenameEv" referenced by "/data/data/com.termux/files/usr/bin/cmake"...
make: *** [Makefile:3065: cmake_check_build_system] Error 1

If that does not work try switching the directories like this:

export LD_LIBRARY_PATH=$PREFIX/lib:/system/vendor/lib64
make alltuners

truboxl from the Termux repo says that can't work: https://github.com/termux/termux-packages/issues/16852#issuecomment-1579047943

.. I tried it anyway, but failed to complete make:

~/CLBlast/build (master) [2]> export LD_LIBRARY_PATH=$PREFIX/lib:/system/vendor/lib64
u0_a1282@localhost ~/CLBlast (master)> make alltuners
[  6%] Built target tuners_common_library
[  8%] Built target clblast_tuner_xgemv
[ 10%] Built target clblast_tuner_transpose_pad
[ 12%] Built target clblast_tuner_copy_fast
[ 80%] Built target clblast
[ 83%] Built target clblast_tuner_routine_xgemm
[ 85%] Built target clblast_tuner_transpose_fast
[ 87%] Built target clblast_tuner_xaxpy
[ 89%] Built target clblast_tuner_routine_xtrsv
[ 91%] Built target clblast_tuner_xdot
[ 92%] Built target clblast_tuner_xgemm_direct
[ 93%] Built target clblast_tuner_xconvgemm
[ 95%] Built target clblast_tuner_xger
[ 96%] Built target clblast_tuner_invert
[ 98%] Built target clblast_tuner_copy_pad
[100%] Built target clblast_tuner_xgemm
* Options given/available:
    -platform 0 [=default]
    -device 0 [=default]
    -precision 32 (single) [=default]
    -m 1024 [=default]
    -n 1024 [=default]
    -alpha 2.00 [=default]
    -fraction 1.00 [=default]
    -runs 10 [=default]
    -max_l2_norm 0.00 [=default]

CLBlast: OpenCL error: clGetPlatformIDs: -1001
make[3]: *** [CMakeFiles/alltuners.dir/build.make:70: CMakeFiles/alltuners] Error 23
make[2]: *** [CMakeFiles/Makefile2:545: CMakeFiles/alltuners.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:552: CMakeFiles/alltuners.dir/rule] Error 2
make: *** [Makefile:377: alltuners] Error 2

Thanks for direction with this. edit: corrected make directory with same result.

alexfarseer commented 1 year ago

@JackJollimore The main problem is that Adreno devices don't support ocl-icd interface. Which is why you need all these env variables hacks.

I can't give you an exact solution because I don't have an Adreno device to test with, but you could probably remove all cmake commands from the Makefile and only run the tuners. That should work, but as I said I don't have a device to test it.

ghost commented 1 year ago

@JackJollimore The main problem is that Adreno devices don't support ocl-icd interface. Which is why you need all these env variables hacks.

I can't give you an exact solution because I don't have an Adreno device to test with, but you could probably remove all cmake commands from the Makefile and only run the tuners. That should work, but as I said I don't have a device to test it.

Thanks. I don't have the skill to remove all cmake commands from the Makefile.

I'll test, but the Makefile might as well be in french to me.

CNugteren commented 1 year ago

So make alltuners is basically a target that does two things: compile all tuners, and run them all. This can also be achieved manually by running each executable separately. Especially in case of issues, that should be the way forward. So retry first as follows:

make clblast_tuner_xaxpy   # or just plain `make`
./clblast_tuner_xaxpy --precision 32 --device 0 --platform 0

See also https://github.com/CNugteren/CLBlast/blob/master/doc/tuning.md, it has the full list of tuner commands.

ghost commented 1 year ago

So make alltuners is basically a target that does two things: compile all tuners, and run them all. This can also be achieved manually by running each executable separately. Especially in case of issues, that should be the way forward. So retry first as follows:

make clblast_tuner_xaxpy   # or just plain `make`
./clblast_tuner_xaxpy --precision 32 --device 0 --platform 0

See also https://github.com/CNugteren/CLBlast/blob/master/doc/tuning.md, it has the full list of tuner commands.

Thanks for clarifying. These gave issues:

./clblast_tuner_xgemm -precision 32
./clblast_tuner_xgemm -precision 3232
./clblast_tuner_xgemm -precision 16
./clblast_tuner_xgemm_direct -precision 16
./clblast_tuner_routine_xtrsv -precision 16 doesnt run

It appears they make a json, but failing at another process:

* Writing a total of 578 results to 'clblast_xgemm_1_32.json'                                       
* Completed tuning process                                                                          
* (2/4) Tuning main GEMM kernel (GEMMK == 0) for random parameters out of larger set                                                                  
* Options given/available:                            -platform 0 [=default]                            
-device 0 [=default]                              
-precision 32 (single) [=default]               
 -m 1024 [=default]                              
 -n 1024 [=default]                           
 -k 1024 [=default]                          
 -alpha 2.00 [=default]                            
-beta 2.00 [=default]                            
 -fraction 512.00 [=default]                      
 -runs 2 [=default]                                -max_l2_norm 0.00 [=default]                                                                    
* Found 120800 configuration(s)                
* Exploring a random subset of 235 configuration(s)                                              
* Parameters explored: GEMMK MWG NWG KWG MDIMC NDIMC MDIMA NDIMB KWI VWM VWN STRM STRN SA SB KREG

...

|   1057.22 ms |    2.0 |     results match |     |  150 |   235 |    0   64  128   16    8   16   32    8 
 2    1    1    0    1    1    1    1 |       8      16 |     128     128 |   OK    230 ms |     93.65 ms |   22.9 |     results match |    

 fish: Job 1, 'LD_LIBRARY_PATH=/vendor/lib64:$…' terminated by signal SIGABRT (Abort)

I'm not sure if that's concerning or not.

I continued, then used this normally:

python ../scripts/database/database.py . ..
make

I hope it's suffecient: https://github.com/CNugteren/CLBlast/issues/1#issuecomment-1599694622

CNugteren commented 1 year ago

Thanks! It seems it did work indeed, the tuning results look fine and have been added to the library here: https://github.com/CNugteren/CLBlast/pull/493

So I guess we can close this issue.