s-u / OpenCL

Interface allowing R to use OpenCL
Other
15 stars 10 forks source link

OpenCL pop-up message #16

Closed Quirinms closed 1 year ago

Quirinms commented 1 year ago

Hi,

upon call to "oclSimpleKernel", a pop up message is created (with potential error message from compiler or the "ok", if everything works). This is a nice feature for developing, however inside of a package it is stopping the swift application flow, especially in benchmarking. Would you consider a second kernel function within your OpenCL R package, which avoids this pop-up message?

Best regards

aaronpuchert commented 1 year ago

Sounds like #13, can you check if your version has the fix?

Quirinms commented 1 year ago

I had the old version 2.2.0 from CRAN. I did an update based on your github rep, but I was not able to install it due to following (rooky?) error:

Screenshot (41)

aaronpuchert commented 1 year ago

The AMDSDK include directory is missing -I. See the R include directory earlier in the gcc command line. You probably need to set PKG_CPPFLAGS="-I C:/Program Files (x86)/AMDSDK/3.0/include", maybe with additional quotes because of the spaces. (Or use PROGRA~1 like for the R include directory.)

Side note: prefer to post text (in triple backticks) instead of screenshots.

Quirinms commented 1 year ago

Adding the -I does not work. The issue is similar to #17 for Nvidia.

Sys.setenv(OCL="C:/Program Files (x86)/AMDSDK/3.0") Sys.setenv(OCL64LIB="C:/Program Files (x86)/AMDSDK/3.0/lib/x64/OpenCL.lib") Sys.setenv(OCL32LIB="C:/Program Files (x86)/AMDSDK/3.0/lib/x86/OpenCL.lib") Sys.setenv(OCLINC="-I -v C:/Program Files (x86)/AMDSDK/3.0/include") install.packages("OpenCL", INSTALL_opts = c('--no-clean-on-error', '--no-test-load'))

results in

NOTE: make sure the run-time DLLs are on PATH!

** libs Warnung: this package has a non-empty 'configure.win' file, so building only the main architecture

using C compiler: 'gcc.exe (GCC) 12.2.0' gcc -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-I -v C:/Program Files (x86)/AMDSDK/3.0/include' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c buffer.c -o buffer.o In file included from buffer.c:2: ocl.h:7:10: fatal error: CL/opencl.h: No such file or directory 7 | #include <CL/opencl.h> | ^~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf:265: buffer.o] Error 1 ERROR: compilation failed for package 'OpenCL'

aaronpuchert commented 1 year ago

Sorry if I wasn't clear, but the directory needs to immediately follow -I. It's -I <include-directory>. If you want to add -v it has be either before or after both of them.

Quirinms commented 1 year ago

Still does not work. No matter which combination of -I and -v, front or back. Though the -I brought the installation to a more advanced point before an error is thrown (see error message below). Note: I did not encounter this error before the R and RTools update (April 2023), if that is any help (neither on Windows with NVIDIA gpu, nor on Windows with AMD gpu).

NOTE: make sure the run-time DLLs are on PATH!

** libs Warnung: this package has a non-empty 'configure.win' file, so building only the main architecture

using C compiler: 'gcc.exe (GCC) 12.2.0' gcc -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files (x86)/AMDSDK/3.0/include/' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c buffer.c -o buffer.o gcc -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files (x86)/AMDSDK/3.0/include/' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c ocl.c -o ocl.o ocl.c: In function 'ocl_context': ocl.c:102:5: warning: 'clCreateCommandQueue' is deprecated [-Wdeprecated-declarations] 102 | queue = clCreateCommandQueue(ctx, device_id, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &last_ocl_error); | ^~~~~ In file included from C:/Program Files (x86)/AMDSDK/3.0/include/CL/opencl.h:42, from ocl.h:7, from ocl.c:2: C:/Program Files (x86)/AMDSDK/3.0/include/CL/cl.h:1359:1: note: declared here 1359 | clCreateCommandQueue(cl_context / context /, | ^~~~~~~~ ocl.c:106:9: warning: 'clCreateCommandQueue' is deprecated [-Wdeprecated-declarations] 106 | queue = clCreateCommandQueue(ctx, device_id, 0, &last_ocl_error); | ^~~~~ C:/Program Files (x86)/AMDSDK/3.0/include/CL/cl.h:1359:1: note: declared here 1359 | clCreateCommandQueue(cl_context / context /, | ^~~~~~~~ gcc -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files (x86)/AMDSDK/3.0/include/' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c reg.c -o reg.o gcc -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG '-IC:/Program Files (x86)/AMDSDK/3.0/include/' -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c wrap.c -o wrap.o gcc -shared -s -static-libgcc -o OpenCL.dll tmp.def buffer.o ocl.o reg.o wrap.o C:/Program Files (x86)/AMDSDK/3.0/lib/x64/OpenCL.lib -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.0/bin/x64 -lR C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: please report this bug collect2.exe: error: ld returned 1 exit status keine DLL erzeugt ERROR: compilation failed for package 'OpenCL'

aaronpuchert commented 1 year ago

Well, the include directory was found, as we no longer see "fatal error: CL/opencl.h: No such file or directory" but instead "In file included from C:/Program Files (x86)/AMDSDK/3.0/include/CL/opencl.h:42", so it did work.

Now this:

C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: internal error: aborting at ../../binutils-2.40/ld/ldlang.c:527 in compare_section

is a bug in the linker. (It even says "please report this bug".) I find the -static-libgcc slightly suspicious, but it's not from us, seems like Rtools simply prefers static linking. The code location tells us there is an unknown sort order.

I would suggest to look first in the MinGW-w64 bug tracker, then over at binutils, and report it at either location. Preferably at MinGW, because they might patch binutils.

Quirinms commented 1 year ago

Thanks! I checked for similar errors, read the articles and wrote a bug report on your suggested page. I guess I will switch back to Ubuntu as long it is not fixed - Windows seems to generate a lot of problems!

aaronpuchert commented 1 year ago

The internal error was now posted as a separate issue in #19. Seems that it has been fixed and just needs to be shipped.