ROCm / MIVisionX

MIVisionX toolkit is a set of comprehensive computer vision and machine intelligence libraries, utilities, and applications bundled into a single toolkit. AMD MIVisionX also delivers a highly optimized open-source implementation of the Khronos OpenVX™ and OpenVX™ Extensions.
https://rocm.docs.amd.com/projects/MIVisionX/en/latest/
MIT License
186 stars 73 forks source link

[loom_shell] Building on fedora 33 Linux fails of !_APPLE #394

Closed arpu closed 4 years ago

arpu commented 4 years ago

Hey,

building on fedora Linux fails on https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/blob/95e4d941fecaa4e24189ab4ecc5ada45d8982203/utilities/loom_shell/loom_shell_util.cpp#L518

is this only needed on windows systems?

kiritigowda commented 4 years ago

@arpu we have not tested MIVisionX on fedora. If you have a fix that does not break existing supported operating systems, we can accept a merge request.

arpu commented 4 years ago

same error is on ubuntu LTS

kiritigowda commented 4 years ago

Hey,

building on fedora Linux fails on

https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/blob/95e4d941fecaa4e24189ab4ecc5ada45d8982203/utilities/loom_shell/loom_shell_util.cpp#L518

is this only needed on windows systems?

@arpu can you send me the error log, I am not able to reproduce this

arpu commented 4 years ago
In file included from /usr/include/CL/cl.h:20,
                 from /home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/../../amd_openvx_extensions/amd_loomsl/live_stitch_api.h:34,
                 from /home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.h:25,
                 from /home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:26:
/usr/include/CL/cl_version.h:22:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)'
   22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)")
      |                                                                                                        ^
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp: In function 'vx_status createOpenCLContext(const char*, const char*, _cl_context**)':
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:519:2: error: 'clEnqueueWaitSignalAMD_fn' was not declared in this scope
  519 |  clEnqueueWaitSignalAMD_fn clEnqueueWaitSignalAMD = (clEnqueueWaitSignalAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueWaitSignalAMD");
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:520:2: error: 'clEnqueueWriteSignalAMD_fn' was not declared in this scope
  520 |  clEnqueueWriteSignalAMD_fn clEnqueueWriteSignalAMD = (clEnqueueWriteSignalAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueWriteSignalAMD");
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:521:2: error: 'clEnqueueMakeBuffersResidentAMD_fn' was not declared in this scope
  521 |  clEnqueueMakeBuffersResidentAMD_fn clEnqueueMakeBuffersResidentAMD = (clEnqueueMakeBuffersResidentAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueMakeBuffersResidentAMD");
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:522:6: error: 'clEnqueueWaitSignalAMD' was not declared in this scope
  522 |  if (clEnqueueWaitSignalAMD && clEnqueueWriteSignalAMD && clEnqueueMakeBuffersResidentAMD) {
      |      ^~~~~~~~~~~~~~~~~~~~~~
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:522:32: error: 'clEnqueueWriteSignalAMD' was not declared in this scope; did you mean 'clEnqueueWriteImage'?
  522 |  if (clEnqueueWaitSignalAMD && clEnqueueWriteSignalAMD && clEnqueueMakeBuffersResidentAMD) {
      |                                ^~~~~~~~~~~~~~~~~~~~~~~
      |                                clEnqueueWriteImage
/home/arpu/Work/githubsources/MIVisionX/utilities/loom_shell/loom_shell_util.cpp:522:59: error: 'clEnqueueMakeBuffersResidentAMD' was not declared in this scope
  522 |  if (clEnqueueWaitSignalAMD && clEnqueueWriteSignalAMD && clEnqueueMakeBuffersResidentAMD) {
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/loom_shell.dir/build.make:82: CMakeFiles/loom_shell.dir/loom_shell_util.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/loom_shell.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
arpu commented 4 years ago

this works for me

iff --git a/utilities/loom_shell/loom_shell_util.cpp b/utilities/loom_shell/loom_shell_util.cpp
index 77d4571..2e6fd0d 100644
--- a/utilities/loom_shell/loom_shell_util.cpp
+++ b/utilities/loom_shell/loom_shell_util.cpp
@@ -515,13 +515,14 @@ vx_status createOpenCLContext(const char * platform, const char * device, cl_con
        if (!found) return Error("ERROR: specified platform '%s' doesn't exist in this system", platform);
        // check if DirectGMA can be is supported
        bool direct_gma_available = false;
-#if !__APPLE__
+#if !__linux__ && !__APPLE__
        clEnqueueWaitSignalAMD_fn clEnqueueWaitSignalAMD = (clEnqueueWaitSignalAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueWaitSignalAMD");
        clEnqueueWriteSignalAMD_fn clEnqueueWriteSignalAMD = (clEnqueueWriteSignalAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueWriteSignalAMD");
        clEnqueueMakeBuffersResidentAMD_fn clEnqueueMakeBuffersResidentAMD = (clEnqueueMakeBuffersResidentAMD_fn)clGetExtensionFunctionAddressForPlatform(platform_id[platform_index], "clEnqueueMakeBuffersResidentAMD");
        if (clEnqueueWaitSignalAMD && clEnqueueWriteSignalAMD && clEnqueueMakeBuffersResidentAMD) {
                direct_gma_available = true;
        }
+
 #endif
        Message("..OpenCL platform#%d: %s %s\n", platform_index, name, direct_gma_available ? "[DirectGMA-OK]" : "[DirectGMA-No]");
        // get OpenCL device
kiritigowda commented 4 years ago

Seems like you are using the public version on OpenCL on Linux - libOpenCL - point your openCL to /opt/rocm/opencl/lib/OpenCL.so and use headers from /opt/rocm/opencl/include

arpu commented 4 years ago

hi thx a lot for your help but it looks like i only can opencl 1.2 ?

arpu@hokuspokus  ~/Work/githubsources/MIVisionX/utilities/runcl   master rocm-3.10.0 ● ?  ldd ./runcl                                                                                                                                                                                              ✔  10298  07:18:52
    linux-vdso.so.1 (0x00007ffd3f376000)
    libOpenCL.so.1 => /opt/rocm-3.9.1/opencl/lib/libOpenCL.so.1 (0x00007f3ae1790000)
    libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f3ae1487000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f3ae129f000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f3ae1159000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f3ae113e000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f3ae0f73000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f3ae0f6a000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3ae0f48000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f3ae0f2e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3ae199a000)
 arpu@hokuspokus  ~/Work/githubsources/MIVisionX/utilities/runcl   master rocm-3.10.0 ● ?  ./runcl -v -gpu                                                                                                                                                                                          ✔  10299  07:18:55
OK: DEVICE # 0 [gfx803]
OK: Using GPU device#0 [gfx803]

OpenCL Device Information:
  DEVICE_NAME              : gfx803
  MAX_CLOCK_FREQUENCY      : 1210 MHz
  DEVICE_VENDOR            : Advanced Micro Devices, Inc.
  DRIVER_VERSION           : 3204.0 (HSA1.1,LC)
  DEVICE_VERSION           : OpenCL 1.2 
  MAX_COMPUTE_UNITS        : 14
  MAX_WORK_ITEM_DIMENSIONS : 3
  MAX_WORK_ITEM_SIZES      : 0 -1625290240 32519
  MAX_WORK_GROUP_SIZE      : 0
  ADDRESS_BITS             : 64 bits
  MEM_BASE_ADDR_ALIGN      : 1024 bits
  MAX_MEM_ALLOC_SIZE       : 3481 MB
  GLOBAL_MEM_SIZE          : 4096 MB
  GLOBAL_MEM_CACHE_TYPE    : READ WRITE
  GLOBAL_MEM_CACHELINE_SIZE: 64 bytes
  GLOBAL_MEM_CACHE_SIZE    : 16 KB
  LOCAL_MEM_TYPE           : LOCAL
  LOCAL_MEM_SIZE           : 64 KB
arpu commented 4 years ago

and same if i direct link to rocm

cmake . -DOpenCL_INCLUDE_DIR=/opt/rocm-3.9.1/opencl/include -DOpenCL_LIBRARY=/opt/rocm-3.9.1/opencl/lib/libOpenCL.so                                                                                     ✔  10328  07:29:14
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for CL_VERSION_2_2
-- Looking for CL_VERSION_2_2 - found
-- Found OpenCL: /opt/rocm-3.9.1/opencl/lib/libOpenCL.so (found version "2.2") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/arpu/Work/githubsources/MIVisionX/utilities/runcl
 arpu@hokuspokus  ~/Work/githubsources/MIVisionX/utilities/runcl   master rocm-3.10.0 ● ?  ./runcl -v -gpu                                                                                                                                                                                          ✔  10329  07:29:19
OK: DEVICE # 0 [gfx803]
OK: Using GPU device#0 [gfx803]

OpenCL Device Information:
  DEVICE_NAME              : gfx803
  MAX_CLOCK_FREQUENCY      : 1210 MHz
  DEVICE_VENDOR            : Advanced Micro Devices, Inc.
  DRIVER_VERSION           : 3204.0 (HSA1.1,LC)
  DEVICE_VERSION           : OpenCL 1.2 
  MAX_COMPUTE_UNITS        : 14
  MAX_WORK_ITEM_DIMENSIONS : 3
  MAX_WORK_ITEM_SIZES      : 0 968071680 32689
  MAX_WORK_GROUP_SIZE      : 0
  ADDRESS_BITS             : 64 bits
  MEM_BASE_ADDR_ALIGN      : 1024 bits
  MAX_MEM_ALLOC_SIZE       : 3481 MB
  GLOBAL_MEM_SIZE          : 4096 MB
  GLOBAL_MEM_CACHE_TYPE    : READ WRITE
  GLOBAL_MEM_CACHELINE_SIZE: 64 bytes
  GLOBAL_MEM_CACHE_SIZE    : 16 KB
  LOCAL_MEM_TYPE           : LOCAL
  LOCAL_MEM_SIZE           : 64 KB
arpu commented 4 years ago

could it be rocm only support opencl 1.2 on this device?

arpu commented 4 years ago

ah yes this can be closed! using rocm include fixed this !