Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
for_each_device.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
18#include "shambackends/sycl.hpp"
19#include <functional>
20
21namespace shamsys {
22
51 std::function<void(u32, const sycl::platform &, const sycl::device &)> fct) {
52
53 u32 key_global = 0;
54 const auto &Platforms = sycl::platform::get_platforms();
55 for (const auto &Platform : Platforms) {
56 const auto &Devices = Platform.get_devices();
57 for (const auto &Device : Devices) {
58 fct(key_global, Platform, Device);
59 key_global++;
60 }
61 }
62 return key_global;
63 }
64
65} // namespace shamsys
std::uint32_t u32
32 bit unsigned integer
namespace for the system handling
u32 for_each_device(std::function< void(u32, const sycl::platform &, const sycl::device &)> fct)
Iterate over all SYCL devices and perform a given function.