Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

How to run dpc++ code on Intel HD Graphic atop Nvidia GPU

nnain1
New Contributor I
2,868 Views

My windows laptop has two Gpus, nvidia GPU and Intel HD Graphic. How to run dpc++ code on Intel Graphic atop Nvidia GPU?

queue myQueue(gpu_selector{}) 

gives Nvidia GPU and can't find Intel Graphic.

But I just like to make Intel Graphic for dpc++ applications, not for any other applications and processes.

My system can detect both as shown in the following image.

devices.png

0 Kudos
1 Solution
nnain1
New Contributor I
2,868 Views

Yes it works. Thanks.

View solution in original post

0 Kudos
4 Replies
GouthamK_Intel
Moderator
2,868 Views

Hi,

Thanks for reaching out to us.

We are working on your issue. We will get back to you with a sample code template with your requirements.  

 

Regards

-Goutham

0 Kudos
GouthamK_Intel
Moderator
2,868 Views

Hi Nyan,

Sorry for the delay in response. 

Please use the below "custom_selector" class in order to select a specific device from available devices.

Here in this "custom_selector" class, we are explicitly selecting Intel iGPU over Nvidia GPU.

#include <CL/sycl.hpp>
#include <string> 

using namespace cl::sycl;

class custom_selector : public device_selector {
 public:
  custom_selector() : device_selector() {}

  int operator()(const device& device) const override {
      std::string device_name=device.get_info<info::device::name>();
      if (device_name.find("Intel")!=std::string::npos) // Selecting Intel Device
           if (device.get_info<info::device::device_type>() == info::device_type::gpu) //Selecting GPU device
               return 100;
     return -1;
  }
};

int main() {
  custom_selector selector;
  queue myQueue(selector);
    {
    std::cout<<"Device Name: "<<myQueue.get_device().get_info<info::device::name>() <<std::endl;
  myQueue.submit([&](handler& cgh) {
    cgh.parallel_for<class my_selector>(dataRange, [=](item<1> item) {
      size_t idx = item.get_linear_id();
//==============Your code Logic==================
    });
  });
}
    myQueue.wait();
  return 0;
}

I hope this resolves your issue. Please let us know if you face any further issues.

 

 

Thanks

Goutham

0 Kudos
nnain1
New Contributor I
2,869 Views

Yes it works. Thanks.

0 Kudos
RahulV_intel
Moderator
2,868 Views

Hi,

Glad to hear that the solution provided has worked. We are closing this thread. 

0 Kudos
Reply