6 Replies Latest reply on Jun 11, 2014 5:34 AM by sureshs

    OpenCL GPU selection criteria

    wayne_static

      Hello,

       

      I'm very curious about the selection process of a GPU in a system with more than one GPU. I'm about to run some experiments on some machines and here is a summary of 2 of the machines:

       

      M1 - contains 2x Sapphire HD 7970 GPUs with SLI disabled and only one GPU powers the displays.

      M2 - contains an MSI HD 7750 and an ASUS HD 7750 GPU. SLI is disabled and the MSI HD 7750 GPU powers the display.

      M1 is running Windows 7 x64 Enterprise, M2 is running Windows 7 x64 Professional and both systems are running Catalyst version 13.9.

       

      In my code I usually use the following to fetch my devices;

       

      deviceList = Context::getInfo<CL_CONTEXT_DEVICES>(&status), where deviceList is of type vector<cl::Device> and status is just error code.

       

      When I execute the program, on machine M1 deviceList[0] happens to be the GPU connected to the display but on M2, deviceList[0] is the idle GPU. Hence the code behaves exactly how I would want it to by running on the idle GPU on M2 and not on the GPU driving the displays.

       

      My question is, is there something I need to know regarding how to correctly select the idle GPU each time, regardless of the system setup?

       

      Many thanks.

        • Re: OpenCL GPU selection criteria
          himanshu.gautam

          Hi

           

          clCreateContextFromType is used to selec particular device type.In the openCL sepc 1.2 table 4.2 gives the list of device types available. But there is no entry for an idle GPU selection .

           

          Please chekc OpenCL spec for more details. Meanwhile if i get any more information i will let you know


            • Re: OpenCL GPU selection criteria
              wayne_static

              Thanks for the reply. I have already gone through the OpenCL 1.2 specs but there is no mention of anything in relation to how OpenCL orders devices. However, I am still not sure what the flag CL_DEVICE_TYPE_DEFAULT is meant to achieve. What does this mean please and who/what chooses or sets the default device? I cannot find any more info on this in the docs or online.

               

              Reason I brought this topic up is, at least in C++ AMP, the criteria for selecting a default device is clearly stated so I was just curious if there is something similar in OpenCL. (Chapter 9 C++ AMP: Accelerated Massive Parallelism with Microsoft Visual C++).

               

              However, I will really be happy if you could tell me more about the CL_DEVICE_TYPE_DEFAULT flag

                • Re: OpenCL GPU selection criteria
                  himanshu.gautam

                  As mentioned in the spec its the default openCL device connected to your system.. Even am not sure which is considered as default devices here. I tried searching in google also but couldn't get any info.

                  Best way is if you multiple opencl devices in hand, try connecting those and mention this flag while quering the device id.

                  Hope this excercise may give you some input.

                  If you get any more information please share here.

                    • Re: OpenCL GPU selection criteria
                      wayne_static

                      Yes I will certainly do this as I had the same thought and will get the result by tomorrow.

                       

                      Also, I hope it's not a problem to ask this here (if not I can always create a new post), but I came across an interesting behaviour.

                       

                      I created a buffer using just CL_MEM_READ_WRITE flag and this is running on the machine with HD 7750. Out of curiosity I tried an input which needs a buffer size of about 1.6 GB of memory and the HD 7750 has just 1 GB of global memory. This buffer is just for reading results back from GPU so I do not call enqueueWriteBuffer on the command queue. The interesting thing is that my program does not crash even though I have exceeded the maximum device memory allocation size. Also when running the program I check task manager in Windows and as soon as the kernel is about to start I notice jump in system main memory usage which suggests that the buffer is now residing in host memory and not on the GPU. The program is a 64-bit version.

                       

                      This seems to happen automatically and the reason I mention/ask this is because there is no mention in the documentations with regards to this behaviour. Am I right to safely assume that this is some sort of behaviour built into the OpenCL framework or AMD APP implementation? And might be probably added to the documentations later?

                       

                      Thanks.

                       

                      EDIT:

                      The CL_DEVICE_TYPE_DEFAULT flag does not make any difference (at least for my setups). On machines with different GPU vendors or APU + discrete GPU, the idle GPU or discrete GPU is selected regardless of whether I use this flag or not. But for the machine with 2x identical HD 7970s, the GPU connected to the display is still being selected. And this seems to be the case as well for another machine with 2x identical NVIDIA 680 GTX.

                      Anyway I will consider the option of hard-coding my program to pick the second device from the list or for AMD machines, something along the line of CL_DEVICE_TOPOLOGY_AMD.

                        • Re: OpenCL GPU selection criteria
                          himanshu.gautam

                          Hi

                          Thanks for your result reported here.

                          Also thanks for sharing your testing experience. I had never tried this kind of cases. Its really a good learning.

                           

                          I will try to check with some experienced persons about this and if i get to know any reasons behind this i will share with you..

                           

                          Till then all the best and try more and do share with us.. We are happy to listen your opinions as well as giving support in resolving your problems.


                          • Re: OpenCL GPU selection criteria
                            sureshs

                            Hi ,

                                     hope you are doing well . Its a nice topic to discuss . As per my experience with opencl , i believe there is no API/FLAG which tells to the user , that this GPU is connected to the monitor . However we can figure that out using a directX/opengl call , You can look into the SimpeDX9/10/11 samples in our APPSDK . The flag  DISPLAY_DEVICE_ACTIVE will help you to find the device which is connected to the monitor . so that you can use the idle GPU for your computations .


                                    Regrading CL_DEVICE_TYPE_DEFAULT or Primary GPU Device , According to the options given in the BIOS Settings it will choose . The peripherals option in the BIOS setting help us to set the primary GPU device . I have seen when i have iGPU & dGPU setup . Before i forced iGPU in the peripherals option(BIOS Setting) , the clinfo displays dGPU first and then displays iGPU . After i forced the iGPU in the BIOS settings , The clinfo displays iGPU first . 
                              When we have 2 or more dGPU alone, i don't know exact behaviour ,but assume the card which is connected to the monitor will act as primary device . I will get back and give more info on it .
                             
                            thanks & regards,
                            Suresh S