@@ -16,45 +16,50 @@ namespace detail {
16
16
sampler_impl::sampler_impl (coordinate_normalization_mode normalizationMode,
17
17
addressing_mode addressingMode,
18
18
filtering_mode filteringMode)
19
- : m_CoordNormMode (normalizationMode), m_AddrMode (addressingMode),
20
- m_FiltMode (filteringMode) {}
19
+ : MCoordNormMode (normalizationMode), MAddrMode (addressingMode),
20
+ MFiltMode (filteringMode) {}
21
21
22
22
sampler_impl::sampler_impl (cl_sampler clSampler, const context &syclContext) {
23
23
24
24
RT::PiSampler Sampler = pi::cast<RT::PiSampler>(clSampler);
25
- m_contextToSampler [syclContext] = Sampler;
25
+ MContextToSampler [syclContext] = Sampler;
26
26
const detail::plugin &Plugin = getSyclObjImpl (syclContext)->getPlugin ();
27
27
Plugin.call <PiApiKind::piSamplerRetain>(Sampler);
28
28
Plugin.call <PiApiKind::piSamplerGetInfo>(
29
29
Sampler, PI_SAMPLER_INFO_NORMALIZED_COORDS, sizeof (pi_bool),
30
- &m_CoordNormMode , nullptr );
30
+ &MCoordNormMode , nullptr );
31
31
Plugin.call <PiApiKind::piSamplerGetInfo>(
32
32
Sampler, PI_SAMPLER_INFO_ADDRESSING_MODE,
33
- sizeof (pi_sampler_addressing_mode), &m_AddrMode , nullptr );
33
+ sizeof (pi_sampler_addressing_mode), &MAddrMode , nullptr );
34
34
Plugin.call <PiApiKind::piSamplerGetInfo>(Sampler, PI_SAMPLER_INFO_FILTER_MODE,
35
35
sizeof (pi_sampler_filter_mode),
36
- &m_FiltMode , nullptr );
36
+ &MFiltMode , nullptr );
37
37
}
38
38
39
39
sampler_impl::~sampler_impl () {
40
- for (auto &Iter : m_contextToSampler) {
40
+ std::lock_guard<mutex_class> Lock (MMutex);
41
+ for (auto &Iter : MContextToSampler) {
41
42
// TODO catch an exception and add it to the list of asynchronous exceptions
42
43
const detail::plugin &Plugin = getSyclObjImpl (Iter.first )->getPlugin ();
43
44
Plugin.call <PiApiKind::piSamplerRelease>(Iter.second );
44
45
}
45
46
}
46
47
47
48
RT::PiSampler sampler_impl::getOrCreateSampler (const context &Context) {
48
- if (m_contextToSampler[Context])
49
- return m_contextToSampler[Context];
49
+ {
50
+ std::lock_guard<mutex_class> Lock (MMutex);
51
+ auto It = MContextToSampler.find (Context);
52
+ if (It != MContextToSampler.end ())
53
+ return It->second ;
54
+ }
50
55
51
56
const pi_sampler_properties sprops[] = {
52
57
PI_SAMPLER_INFO_NORMALIZED_COORDS,
53
- static_cast <pi_sampler_properties>(m_CoordNormMode ),
58
+ static_cast <pi_sampler_properties>(MCoordNormMode ),
54
59
PI_SAMPLER_INFO_ADDRESSING_MODE,
55
- static_cast <pi_sampler_properties>(m_AddrMode ),
60
+ static_cast <pi_sampler_properties>(MAddrMode ),
56
61
PI_SAMPLER_INFO_FILTER_MODE,
57
- static_cast <pi_sampler_properties>(m_FiltMode ),
62
+ static_cast <pi_sampler_properties>(MFiltMode ),
58
63
0 };
59
64
60
65
RT::PiResult errcode_ret = PI_SUCCESS;
@@ -69,18 +74,19 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) {
69
74
errcode_ret);
70
75
71
76
Plugin.checkPiResult (errcode_ret);
72
- m_contextToSampler[Context] = resultSampler;
77
+ std::lock_guard<mutex_class> Lock (MMutex);
78
+ MContextToSampler[Context] = resultSampler;
73
79
74
- return m_contextToSampler[Context] ;
80
+ return resultSampler ;
75
81
}
76
82
77
- addressing_mode sampler_impl::get_addressing_mode () const { return m_AddrMode ; }
83
+ addressing_mode sampler_impl::get_addressing_mode () const { return MAddrMode ; }
78
84
79
- filtering_mode sampler_impl::get_filtering_mode () const { return m_FiltMode ; }
85
+ filtering_mode sampler_impl::get_filtering_mode () const { return MFiltMode ; }
80
86
81
87
coordinate_normalization_mode
82
88
sampler_impl::get_coordinate_normalization_mode () const {
83
- return m_CoordNormMode ;
89
+ return MCoordNormMode ;
84
90
}
85
91
86
92
} // namespace detail
0 commit comments