File: sycl_device.cpp

package info (click to toggle)
taskflow 3.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 45,948 kB
  • sloc: cpp: 39,058; xml: 35,572; python: 12,935; javascript: 1,732; makefile: 59; sh: 16
file content (57 lines) | stat: -rw-r--r-- 2,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This program pulls out all platforms and devices using SYCL.

#include <taskflow/sycl/syclflow.hpp>

int main() {

  std::vector<sycl::platform> platforms = sycl::platform::get_platforms();

  // looping over platforms
  for (const auto& platform : platforms) {

    std::cout << "Platform   : "
	            << platform.get_info<sycl::info::platform::name>() << '\n'
              << "is_host    : "
              << platform.is_host() << '\n'
              << "version    : "
              << platform.get_info<sycl::info::platform::version>() << '\n'
              << "vendor     : "
              << platform.get_info<sycl::info::platform::vendor>() << '\n'
              << "profile    : "
              << platform.get_info<sycl::info::platform::profile>() << '\n';
              //<< "extensions :"
              //<< platform.get_info<sycl::info::platform::extensions>() << '\n';

    // getting the list of devices from the platform
    std::vector<sycl::device> devices = platform.get_devices();

    // looping over devices
    for (const auto& device : devices) {

      std::cout << "  Device             : "
		            << device.get_info<sycl::info::device::name>() << '\n'
                << "  vendor             : "
                << device.get_info<sycl::info::device::vendor>() << '\n'
                << "  version            : "
                << device.get_info<sycl::info::device::version>() << '\n'
                << "  is_host            : " << device.is_host() << '\n'
                << "  is_cpu             : " << device.is_cpu() << '\n'
                << "  is_gpu             : " << device.is_gpu() << '\n'
                << "  is_accelerator     : " << device.is_accelerator() << '\n'
                << "  max_work_group_size: "
                << device.get_info<sycl::info::device::max_work_group_size>() << '\n'
                << "  local_mem_size     : "
                << device.get_info<sycl::info::device::local_mem_size>() << '\n';

      // submitting a kernel to the sycl device
      auto queue = sycl::queue(device);
      queue.submit([](sycl::handler& handler){
        handler.single_task([](){});
      });
    }

    std::cout << std::endl;
  }

  return 0;
}