preda / gpuowl

GPU Mersenne primality test.
GNU General Public License v3.0
176 stars 39 forks source link

error: variable has address space that is not supported in program scope declaration when running gpuowl #279

Closed luizfzs closed 2 months ago

luizfzs commented 8 months ago

I'm trying to get gpuowl running on an old system. clinfo works. I've compiled the code since I got the whole driver dance to work. When I run ./gpuowl -prp 82589933, this is what I get:

20240328 15:23:07  GpuOwl VERSION v7.5-10-g61a08e2
20240328 15:23:07  GpuOwl VERSION v7.5-10-g61a08e2
20240328 15:23:07  config: -prp 82589933
20240328 15:23:07  device 0, unique id '', driver '470.239.06'
20240328 15:23:07 82589933 FFT: 4.50M 1K:9:256 (17.50 bpw)
20240328 15:23:07 82589933 OpenCL args "-DEXP=82589933u -DWIDTH=1024u -DSMALL_HEIGHT=256u -DMIDDLE=9u -DWEIGHT_STEP=0.41118935041770088 -DIWEIGHT_STEP=-0.29137787235709517 -DIWEIGHTS={0,-0.49785468021484264,-0.49570015563572417,-0.49353638676819128,-0.49136333394833431,-0.48918095734206013,-0.4869892169443617,-0.48478807257858503,} -DFWEIGHTS={0,0.99145538273233247,0.98294727070679044,0.97447550796171278,0.96603993920175468,0.95764040979504106,0.94927676577033182,0.94094885381419968,}  -cl-std=CL2.0 -cl-finite-math-only "
20240328 15:23:07 82589933 ASM compilation failed, retrying compilation using NO_ASM
20240328 15:23:07 82589933 OpenCL compilation error -11 (args -DEXP=82589933u -DWIDTH=1024u -DSMALL_HEIGHT=256u -DMIDDLE=9u -DWEIGHT_STEP=0.41118935041770088 -DIWEIGHT_STEP=-0.29137787235709517 -DIWEIGHTS={0,-0.49785468021484264,-0.49570015563572417,-0.49353638676819128,-0.49136333394833431,-0.48918095734206013,-0.4869892169443617,-0.48478807257858503,} -DFWEIGHTS={0,0.99145538273233247,0.98294727070679044,0.97447550796171278,0.96603993920175468,0.95764040979504106,0.94927676577033182,0.94094885381419968,}  -cl-std=CL2.0 -cl-finite-math-only  -DNO_ASM=1)
20240328 15:23:07 82589933 <kernel>:1368:16: error: variable has address space that is not supported in program scope declaration
global double2 TRIG_2SH[SMALL_HEIGHT / 4 + 1];

From clinfo, it seems I have OpenCL 1.2 installed.

Number of devices                                 1
  Device Name                                     NVIDIA GeForce GT 650M
  Device Vendor                                   NVIDIA Corporation
  Device Vendor ID                                0x10de
  Device Version                                  OpenCL 3.0 CUDA
  Device UUID                                     87e0283c-2fd4-f05b-caf8-551522ee6935
  Driver UUID                                     87e0283c-2fd4-f05b-caf8-551522ee6935
  Valid Device LUID                               No
  Device LUID                                     6d69-637300000000
  Device Node Mask                                0
  Device Numeric Version                          0xc00000 (3.0.0)
  Driver Version                                  470.239.06
  Device OpenCL C Version                         OpenCL C 1.2

Is that supported or do I need some newer version of OpenCL?

chocolate42 commented 7 months ago

I'm pretty sure opencl 2 is required but could be wrong.

preda commented 7 months ago

Yes it's because global variables in an OpenCL program were added only at some point in OpenCL (I'd guess in OpenCL 2.0?), and it seems this is the problem.

You might try to compile PRPLL, run with "-use NO_ASM" on Nvidia, and see what error you hit there. https://github.com/preda/gpuowl/tree/prpll

luizfzs commented 7 months ago

@preda thanks for the suggestion. Below are my findings. make doesn't end successfully, due to missing a library to compile prpll-amd, however it compiles prpll so it's fine.

When running it like ./prpll -prp 1234567 -use NO_ASM I got a different error.

20240401 13:18:57  PRPLL 0.6-2-gf8d1d7c
20240401 13:18:57  PRPLL 0.6-2-gf8d1d7c
20240401 13:18:57  config: -prp 1234567 -use NO_ASM
20240401 13:18:57  device 0, OpenCL 470.239.06, unique id ''
20240401 13:18:57 0 1234567 FFT: 256K 256:2:256 (4.71 bpw)
20240401 13:18:57 0 1234567 Reused smallTrig
20240401 13:18:57 0 1234567 Using long carry!
20240401 13:18:57 0 1234567 In file included from <kernel>:1:
carryfused.cl:86:46: error: use of undeclared identifier 'memory_scope_device'
    work_group_barrier(CLK_GLOBAL_MEM_FENCE, memory_scope_device);
                                             ^
carryfused.cl:88:7: warning: implicit declaration of function 'atomic_store' is invalid in C99
      atomic_store((atomic_uint *) &ready[gr], 1);
      ^
carryfused.cl:88:21: error: use of undeclared identifier 'atomic_uint'
      atomic_store((atomic_uint *) &ready[gr], 1);
                    ^
carryfused.cl:88:34: error: expected expression
      atomic_store((atomic_uint *) &ready[gr], 1);
                                 ^
carryfused.cl:96:12: warning: implicit declaration of function 'atomic_load' is invalid in C99
    while(!atomic_load((atomic_uint *) &ready[gr - 1]));
           ^
carryfused.cl:96:25: error: use of undeclared identifier 'atomic_uint'
    while(!atomic_load((atomic_uint *) &ready[gr - 1]));
                        ^
carryfused.cl:96:38: error: expected expression
    while(!atomic_load((atomic_uint *) &ready[gr - 1]));
                                     ^
carryfused.cl:98:44: error: use of undeclared identifier 'memory_scope_device'
  work_group_barrier(CLK_GLOBAL_MEM_FENCE, memory_scope_device);
                                           ^

20240401 13:18:57 0 1234567 Compiling 'carryfused.cl' error BUILD_PROGRAM_FAILURE (-11) (args -cl-finite-math-only -cl-std=CL2.0  -DEXP=1234567u -DWIDTH=256u -DSMALL_HEIGHT=256u -DMIDDLE=2u -DWEIGHT_STEP=0.22306462926440029 -DIWEIGHT_STEP=-0.18238171878011078 -DIWEIGHTS={0,-0.33150034621503416,-0.10621642577876156,-0.40250599007441273,-0.20115092245230795,-0.46596966823292851,-0.2860018162060845,-0.045384922661346139,} -DFWEIGHTS={0,0.49588708735766496,0.11883908906169915,0.67365694615840821,0.25180090721241277,0.87255281304165877,0.40056378671214449,0.047542641781725854,} -DNO_ASM=1 )
20240401 13:18:57 0 1234567 Can't compile carryfused.cl
20240401 13:18:57 0  Exception "Can't compile carryfused.cl"
20240401 13:18:57  Bye

I've noticed some warnings about C99. My gcc is gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04), which IIRC, should support C20. I'm using the Makefile I got from the repository, and it has the C20 flag CXXFLAGS = -Wall -O2 -DNDEBUG -std=c++20.

Some other things I noticed are the flags -cl-std=CL2.0 and that the NO_ASM are set.

Is it possible some files/changes haven't been committed to this branch?

preda commented 7 months ago

It seems the OpenCL you're using does not understand the memory_scope_device in work_group_barrier(), which means you probably need OpenCL 2.0 support.

The makefile missing lib is an unrelated problem, I fixed that one in the makefile in a recent commit.

preda commented 2 months ago

Closing this as I'm not investigating OpenCL 1.2 support ATM.