Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nnain1
New Contributor I
440 Views

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

Jump to solution

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

Tags (1)
0 Kudos
1 Solution
nnain1
New Contributor I
440 Views

Yes it works. Thanks.

View solution in original post

4 Replies
GouthamK_Intel
Moderator
440 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

GouthamK_Intel
Moderator
440 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

nnain1
New Contributor I
441 Views

Yes it works. Thanks.

View solution in original post

RahulV_intel
Moderator
440 Views

Hi,

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

Reply