Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
SYCLEnvInternal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#pragma once
9
10#include <alien/kernels/sycl/SYCLPrecomp.h>
11
12#ifdef USE_SYCL2020
13#include <sycl/sycl.hpp>
14#else
15#include <CL/sycl.hpp>
16#endif
17
18
19namespace Alien
20{
21
22namespace SYCLInternal
23{
24#ifndef USE_SYCL2020
25 using namespace cl ;
26#endif
27
28 struct ALIEN_EXPORT EnvInternal
29 {
30 EnvInternal()
31 : m_queue(sycl::gpu_selector{})
32 {
33
34 auto device = m_queue.get_device();
35
36 m_max_num_groups = m_queue.get_device().get_info<sycl::info::device::max_compute_units>();
37 // getting the maximum work group size per thread
38 m_max_work_group_size = m_queue.get_device().get_info<sycl::info::device::max_work_group_size>();
39 m_subgroup_size = m_queue.get_device().get_info<sycl::info::device::sub_group_sizes>()[0];
40 m_max_num_subgroups_per_group = m_max_work_group_size/m_subgroup_size ;
41 m_max_num_threads = m_max_num_groups * m_max_work_group_size;
42
43 std::cout << "========== SYCL QUEUE INFO ===============" << std::endl;
44 std::cout<< " DEVICE NAME = " << m_queue.get_device().get_info<sycl::info::device::name>() << std::endl;
45 std::cout << "MAX NB GROUPS = " << m_max_num_groups << std::endl;
46 std::cout << "MAX WORK GROUP SIZE = " << m_max_work_group_size << std::endl;
47 std::cout << "SUB GROUP SIZE = " << m_subgroup_size << std::endl ;
48 std::cout << "MAX NB SUBGROUPs PER GROUP = " << m_max_num_subgroups_per_group << std::endl;
49 std::cout << "MAX NB THREADS = " << m_max_num_threads << std::endl;
50 }
51
52 EnvInternal(sycl::device selected_device, int device_id)
53 : m_queue(selected_device,sycl::property::queue::in_order{})
54 , m_device_id(device_id)
55 {
56
57 auto device = m_queue.get_device();
58
59 m_max_num_groups = m_queue.get_device().get_info<sycl::info::device::max_compute_units>();
60 // getting the maximum work group size per thread
61 m_max_work_group_size = m_queue.get_device().get_info<sycl::info::device::max_work_group_size>();
62 m_subgroup_size = m_queue.get_device().get_info<sycl::info::device::sub_group_sizes>()[0];
63 m_max_num_subgroups_per_group = m_max_work_group_size/m_subgroup_size ;
64 m_max_num_threads = m_max_num_groups * m_max_work_group_size;
65
66 std::cout << "========== SYCL QUEUE INFO ===============" << std::endl;
67 std::cout<< " DEVICE NAME = " << m_queue.get_device().get_info<sycl::info::device::name>() << std::endl;
68 std::cout << "MAX NB GROUPS = " << m_max_num_groups << std::endl;
69 std::cout << "MAX WORK GROUP SIZE = " << m_max_work_group_size << std::endl;
70 std::cout << "SUB GROUP SIZE = " << m_subgroup_size << std::endl ;
71 std::cout << "MAX NB SUBGROUPs PER GROUP = " << m_max_num_subgroups_per_group << std::endl;
72 std::cout << "MAX NB THREADS = " << m_max_num_threads << std::endl;
73 }
74
75
76 sycl::queue& queue()
77 {
78 return m_queue;
79 }
80
81 std::size_t maxNumGroups()
82 {
83 return m_max_num_groups;
84 }
85
86 std::size_t maxWorkGroupSize()
87 {
88 return m_max_work_group_size;
89 }
90
91 std::size_t maxNumThreads()
92 {
93 return m_max_num_threads;
94 }
95
96 int deviceId()
97 {
98 return m_device_id;
99 }
100
101 static int printPlatformInfo()
102 {
103 // Loop over all available SYCL platforms.
104 for (const sycl::platform& platform :
105 sycl::platform::get_platforms()) {
106
107 // Print some information about the platform.
108 std::cout << "============ Platform ============" << std::endl;
109 std::cout << " Name : "
110 << platform.get_info<sycl::info::platform::name>()
111 << std::endl;
112 std::cout << " Vendor : "
113 << platform.get_info<sycl::info::platform::vendor>()
114 << std::endl;
115 std::cout << " Version: "
116 << platform.get_info<sycl::info::platform::version>()
117 << std::endl;
118
119 // Loop over all devices available from this platform.
120 for (const sycl::device& device : platform.get_devices()) {
121
122 // Print some information about the device.
123 std::cout << "------------- Device -------------" << std::endl;
124 std::cout << " Name : "
125 << device.get_info<sycl::info::device::name>()
126 << std::endl;
127 std::cout << " Vendor : "
128 << device.get_info<sycl::info::device::vendor>()
129 << std::endl;
130 std::cout << " Version: "
131 << device.get_info<sycl::info::device::version>()
132 << std::endl;
133 }
134 }
135 return 0;
136 }
137
138 // clang-format off
139 //sycl::default_selector m_device_selector;
140 int m_device_id = 0;
141 sycl::queue m_queue;
142 std::size_t m_max_num_groups = 0 ;
143 std::size_t m_max_work_group_size = 0 ;
144 std::size_t m_subgroup_size = 0 ;
145 std::size_t m_max_num_subgroups_per_group = 0 ;
146 std::size_t m_max_num_threads = 0 ;
147 // clang-format on
148 };
149} // namespace SYCLInternal
150} // namespace Alien
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17