14 Replies Latest reply on Sep 4, 2010 12:39 PM by genaganna

    Incorrect Memory Size

    whiteshadow
      Why memory size detected by OpenCL always smaller than actual memory size?

      Sorry if this question is already ask somewhere and answer already provide, if so please point me to the correct place.

       

      I have a machine with 4GB RAM memory and HD5870 with 1GB memory. When I use clGetDeviceInfo to get CL_DEVICE_GLOBAL_MEM_SIZE it only return 3GB RAM in my machine and only 256MB video memory from HD5870 which is actually much smaller than the original value.

      At first I though memory used by OS will deducted but end up the value getting was not.

      When I try to allocate 140MB memory from HD5870, it fail and said memory not enough. In the end, I was able to use less than 110MB than 1GB memory provided by the graphic card.

      I wish someone can tell me what is actually happen, that will be gratefully to help me understanding more in OpenCL.

       

      Thank you.

        • Incorrect Memory Size
          MicahVillmow
          If you are running 32bit windows, Microsoft limits the amount of ram that is addressable in windows to 3GB for some versions, more information can be found here.
          http://msdn.microsoft.com/en-u.../aa366778(VS.85).aspx

          The memory driver model on Vista/Win7 is different than XP and thus might cause failures in allocation below what your device is capable of. Information on calculating how much is available can be found here:
          http://msdn.microsoft.com/en-us/library/dd163270.aspx

            • Incorrect Memory Size
              whiteshadow

              Thank you MicahVillmow for the answer.

               

              I actually testing on Windows 7 64-bit machine and I double checked my machine and it fully detected and allocated all 4GB memory.

              Regrading graphic card memory allocation, do you mean that it is possible that the OS already used up most of the memory and only left a bit for me? But OpenCL should show me the device got 1GB global memory since HD5870 has a dedicated video memory 1GB, but it only show 256MB only.

               

              Thank you again.

                • Incorrect Memory Size
                  nou

                  i tested on linux and i get that CL_GLOBAL_MEM_SIZE is 3072MB. i have 4GB of RAM. so i tested alloc 4*1GB of cl_mem. 1GB per buffer because CL_DEVICE_MAX_MEM_ALLOC_SIZE is only 1GB. i must for this test turn on swap of 2GB and whole it get 4.5GB of memory. so i think when is device memory too small OpenCL it will move buffers to RAM and OS to swap. i tested it only on CPU.

                  so try alloc two or three 100MB buffers and check value of CL_DEVICE_MAX_MEM_ALLOC_SIZE

                  EDIT: i tested it now on ubuntu 9.04 x64 radeon 4870 with 1GB VRAM. global_mem_size is reported 256MB and alloc_size is too 256MB. so i try create three 228MB buffers. but i get error that there is not enough video memory.

                  so i hope that this limit is only for this beta and it will be removed. because utilize only 1/4 of total memory is little inefficient

                    • Incorrect Memory Size
                      mfried

                      I'm seeing the same thing in the v1.0 release of ATI Stream SDK 2.0. My 5870 card only shows 256MB of global memory, and the CPU against the x86 OpenCL shows 1GB, and against the x64 DLL shows 3GB. My computer has 12GB of DDR3 and 2x Intel Nehalem CPUs and an nVidia GTX-260 and Tesla C1060 (in addition to the Radeon 5870 - and there's one x16 slot left to test other GPUs).

                      Most interestingly, the x64 DLLs on Windows add cl_khr_in64_base_atomics and _extended_atomics but no fp64, even for the CPU. Also, none of the OpenCL Image features are supported via the Stream SDK, and Fused Multiply/Add is also not supported. This is as of driver version CAL 1.4.515.

                    • Incorrect Memory Size
                      hazeman

                       

                      Originally posted by: whiteshadow

                       

                      Regrading graphic card memory allocation, do you mean that it is possible that the OS already used up most of the memory and only left a bit for me? But OpenCL should show me the device got 1GB global memory since HD5870 has a dedicated video memory 1GB, but it only show 256MB only.

                       

                       

                       

                      This 256MB is quite significant value for CAL ( OpenCL is written on top of CAL ). This is exactly the maximum size of allocable image ( buffer ) - this size comes from 8128*8128*(4*sizeof(float)). The value 8128 is maximum image width/height for 4xxx/5xxx hardware.

                      The total memory limit of 256MB looks like next example of poor compiler design from ATI side ( many basic optimizations are missing which make 4xxx family totaly unusable for any serious computations with OpenCL- the 5xxx family also has a lot of other problems ).

                      It looks like the design team went easy way and used one buffer as whole memory. It's easy and inefficient solution to the problem of multiple input/outputs in CAL kernel. I have to admit that at some point when I was writing some CAL kernel I did wonder how they solved it - now I know .

                      So back to your question - the system didn't use graphics cards memory. Simply OpenCL compiler doesn't know how to use more.