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<< " DEVICE ID = " << m_device_id << std::endl;
69 std::cout << "MAX NB GROUPS = " << m_max_num_groups << std::endl;
70 std::cout << "MAX WORK GROUP SIZE = " << m_max_work_group_size << std::endl;
71 std::cout << "SUB GROUP SIZE = " << m_subgroup_size << std::endl ;
72 std::cout << "MAX NB SUBGROUPs PER GROUP = " << m_max_num_subgroups_per_group << std::endl;
73 std::cout << "MAX NB THREADS = " << m_max_num_threads << std::endl;
74 }
75
76
77 sycl::queue& queue()
78 {
79 return m_queue;
80 }
81
82 std::size_t maxNumGroups()
83 {
84 return m_max_num_groups;
85 }
86
87 std::size_t maxWorkGroupSize()
88 {
89 return m_max_work_group_size;
90 }
91
92 std::size_t maxNumThreads()
93 {
94 return m_max_num_threads;
95 }
96
97 int deviceId()
98 {
99 return m_device_id;
100 }
101
102 static int printPlatformInfo()
103 {
104 // Loop over all available SYCL platforms.
105 for (const sycl::platform& platform :
106 sycl::platform::get_platforms()) {
107
108 // Print some information about the platform.
109 std::cout << "============ Platform ============" << std::endl;
110 std::cout << " Name : "
111 << platform.get_info<sycl::info::platform::name>()
112 << std::endl;
113 std::cout << " Vendor : "
114 << platform.get_info<sycl::info::platform::vendor>()
115 << std::endl;
116 std::cout << " Version: "
117 << platform.get_info<sycl::info::platform::version>()
118 << std::endl;
119
120 // Loop over all devices available from this platform.
121 for (const sycl::device& device : platform.get_devices()) {
122
123 // Print some information about the device.
124 std::cout << "------------- Device -------------" << std::endl;
125 std::cout << " Name : "
126 << device.get_info<sycl::info::device::name>()
127 << std::endl;
128 std::cout << " Vendor : "
129 << device.get_info<sycl::info::device::vendor>()
130 << std::endl;
131 std::cout << " Version: "
132 << device.get_info<sycl::info::device::version>()
133 << std::endl;
134 }
135 }
136 return 0;
137 }
138
139 // clang-format off
140 //sycl::default_selector m_device_selector;
141 int m_device_id = 0;
142 sycl::queue m_queue;
143 std::size_t m_max_num_groups = 0 ;
144 std::size_t m_max_work_group_size = 0 ;
145 std::size_t m_subgroup_size = 0 ;
146 std::size_t m_max_num_subgroups_per_group = 0 ;
147 std::size_t m_max_num_threads = 0 ;
148 // clang-format on
149 };
150} // namespace SYCLInternal
151} // namespace Alien
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17