-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathonce_per_unit.h
50 lines (43 loc) · 1.29 KB
/
once_per_unit.h
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
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Factory methods for objects created once per translation unit
//
*******************************************************************************/
#ifndef __SYCLCTS_TESTS_COMMON_ONCE_PER_UNIT_H
#define __SYCLCTS_TESTS_COMMON_ONCE_PER_UNIT_H
#include "../../util/logger.h"
#include "../common/get_cts_object.h"
namespace detail {
/**
* @brief Helper class for once_per_unit::log() function
*/
struct log_notice {
log_notice(sycl_cts::util::logger &log, const std::string &message) {
log.note(message);
}
};
} // namespace detail
namespace {
/**
* All symbols have internal linkage here;
* special attention to the ODR rules should be made
*/
namespace once_per_unit {
/**
* @brief Factory method; provides unique queue instance per compilation unit
*/
inline sycl::queue &get_queue() {
static auto q = sycl_cts::util::get_cts_object::queue();
return q;
}
/**
* @brief Provide possibility to log message once per translation unit
*/
inline void log(sycl_cts::util::logger& log, const std::string& message) {
static const detail::log_notice log_just_once(log, message);
}
} // namespace once_per_unit
} // namespace
#endif // __SYCLCTS_TESTS_COMMON_ONCE_PER_UNIT_H