Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
DeviceQueue.cpp
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
17#include "shamcmdopt/env.hpp"
18#include "shamcomm/logs.hpp"
19#include <utility>
20
21std::string SHAMROCK_WAIT_AFTER_SUBMIT = shamcmdopt::getenv_str_default_register(
22 "SHAMROCK_WAIT_AFTER_SUBMIT", "0", "Make queues wait after submit (default: 0)");
23
24namespace sham {
25
26 auto build_queue = [](sycl::context &ctx, sycl::device &dev, bool in_order) -> sycl::queue {
27 if (in_order) {
28 return sycl::queue{ctx, dev, sycl::property::queue::in_order{}};
29 } else {
30 return sycl::queue{ctx, dev};
31 }
32 };
33
34 auto parse_wait_after_submit = []() -> bool {
35 bool ret = SHAMROCK_WAIT_AFTER_SUBMIT == "1";
36
37 if (ret) {
38 shamcomm::logs::warn_ln("Backends", "DeviceQueue :", "wait_after_submit is on !");
39 }
40
41 return ret;
42 };
43
44 bool env_var_wait_after_submit_set = parse_wait_after_submit();
45
47 std::string queue_name, std::shared_ptr<DeviceContext> _ctx, bool in_order)
48 : queue_name(std::move(queue_name)), ctx(std::move(_ctx)), in_order(in_order),
49 q(build_queue(ctx->ctx, ctx->device->dev, in_order)),
50 wait_after_submit(env_var_wait_after_submit_set) {}
51
52} // namespace sham
DeviceQueue(std::string queue_name, std::shared_ptr< DeviceContext > ctx, bool in_order)
Create a device queue.
namespace for backends this one is named only sham since shambackends is too long to write
@ device
Device memory.
std::string getenv_str_default_register(const char *env_var, std::string default_val, std::string desc)
Get the content of the environment variable if it exist and register it documentation,...
Definition env.hpp:88
STL namespace.
void warn_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
Definition logs.hpp:133