Skip to content

Commit af2bf96

Browse files
authored
[SYCL] Use int instead of pi_mem_advice in (queue|handler)::mem_advise (#4100)
- Update these API signatures according to the SYCL 2020 spec. - Keep `queue::mem_advise(const void *, size_t, pi_mem_advice)`, which was available in previous releases, but mark it as deprecated.
1 parent fdb610d commit af2bf96

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

sycl/include/CL/sycl/handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ class __SYCL_EXPORT handler {
22952295
/// \param Ptr is a USM pointer to the allocation.
22962296
/// \param Length is a number of bytes in the allocation.
22972297
/// \param Advice is a device-defined advice for the specified allocation.
2298-
void mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);
2298+
void mem_advise(const void *Ptr, size_t Length, int Advice);
22992299

23002300
private:
23012301
std::shared_ptr<detail::queue_impl> MQueue;

sycl/include/CL/sycl/queue.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,18 @@ class __SYCL_EXPORT queue {
494494
/// \param Length is a number of bytes in the allocation.
495495
/// \param Advice is a device-defined advice for the specified allocation.
496496
/// \return an event representing advice operation.
497+
__SYCL2020_DEPRECATED("use the overload with int Advice instead")
497498
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);
498499

500+
/// Provides additional information to the underlying runtime about how
501+
/// different allocations are used.
502+
///
503+
/// \param Ptr is a USM pointer to the allocation.
504+
/// \param Length is a number of bytes in the allocation.
505+
/// \param Advice is a device-defined advice for the specified allocation.
506+
/// \return an event representing advice operation.
507+
event mem_advise(const void *Ptr, size_t Length, int Advice);
508+
499509
/// Provides additional information to the underlying runtime about how
500510
/// different allocations are used.
501511
///
@@ -504,8 +514,7 @@ class __SYCL_EXPORT queue {
504514
/// \param Advice is a device-defined advice for the specified allocation.
505515
/// \param DepEvent is an event that specifies the kernel dependencies.
506516
/// \return an event representing advice operation.
507-
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice,
508-
event DepEvent);
517+
event mem_advise(const void *Ptr, size_t Length, int Advice, event DepEvent);
509518

510519
/// Provides additional information to the underlying runtime about how
511520
/// different allocations are used.
@@ -516,7 +525,7 @@ class __SYCL_EXPORT queue {
516525
/// \param DepEvents is a vector of events that specifies the kernel
517526
/// dependencies.
518527
/// \return an event representing advice operation.
519-
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice,
528+
event mem_advise(const void *Ptr, size_t Length, int Advice,
520529
const vector_class<event> &DepEvents);
521530

522531
/// Provides hints to the runtime library that data should be made available

sycl/source/handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void handler::prefetch(const void *Ptr, size_t Count) {
506506
setType(detail::CG::PREFETCH_USM);
507507
}
508508

509-
void handler::mem_advise(const void *Ptr, size_t Count, pi_mem_advice Advice) {
509+
void handler::mem_advise(const void *Ptr, size_t Count, int Advice) {
510510
throwIfActionIsCreated();
511511
MDstPtr = const_cast<void *>(Ptr);
512512
MLength = Count;
@@ -522,7 +522,7 @@ void handler::mem_advise(const void *Ptr, size_t Count, pi_mem_advice Advice) {
522522

523523
detail::ExtendedMemberT EMember = {
524524
detail::ExtendedMembersType::HANDLER_MEM_ADVICE,
525-
std::make_shared<pi_mem_advice>(Advice)};
525+
std::make_shared<pi_mem_advice>(pi_mem_advice(Advice))};
526526

527527
ExtendedMembersVec->push_back(EMember);
528528
}

sycl/source/queue.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,21 @@ event queue::memcpy(void *Dest, const void *Src, size_t Count,
105105
}
106106

107107
event queue::mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice) {
108-
return impl->mem_advise(impl, Ptr, Length, Advice, {});
108+
return mem_advise(Ptr, Length, int(Advice));
109109
}
110110

111-
event queue::mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice,
111+
event queue::mem_advise(const void *Ptr, size_t Length, int Advice) {
112+
return impl->mem_advise(impl, Ptr, Length, pi_mem_advice(Advice), {});
113+
}
114+
115+
event queue::mem_advise(const void *Ptr, size_t Length, int Advice,
112116
event DepEvent) {
113-
return impl->mem_advise(impl, Ptr, Length, Advice, {DepEvent});
117+
return impl->mem_advise(impl, Ptr, Length, pi_mem_advice(Advice), {DepEvent});
114118
}
115119

116-
event queue::mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice,
120+
event queue::mem_advise(const void *Ptr, size_t Length, int Advice,
117121
const vector_class<event> &DepEvents) {
118-
return impl->mem_advise(impl, Ptr, Length, Advice, DepEvents);
122+
return impl->mem_advise(impl, Ptr, Length, pi_mem_advice(Advice), DepEvents);
119123
}
120124

121125
event queue::submit_impl(std::function<void(handler &)> CGH,

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,8 +3647,9 @@ _ZN2cl4sycl5eventC2EP9_cl_eventRKNS0_7contextE
36473647
_ZN2cl4sycl5eventC2ESt10shared_ptrINS0_6detail10event_implEE
36483648
_ZN2cl4sycl5eventC2Ev
36493649
_ZN2cl4sycl5queue10mem_adviseEPKvm14_pi_mem_advice
3650-
_ZN2cl4sycl5queue10mem_adviseEPKvm14_pi_mem_adviceNS0_5eventE
3651-
_ZN2cl4sycl5queue10mem_adviseEPKvm14_pi_mem_adviceRKSt6vectorINS0_5eventESaIS6_EE
3650+
_ZN2cl4sycl5queue10mem_adviseEPKvmi
3651+
_ZN2cl4sycl5queue10mem_adviseEPKvmiNS0_5eventE
3652+
_ZN2cl4sycl5queue10mem_adviseEPKvmiRKSt6vectorINS0_5eventESaIS5_EE
36523653
_ZN2cl4sycl5queue10wait_proxyERKNS0_6detail13code_locationE
36533654
_ZN2cl4sycl5queue11submit_implESt8functionIFvRNS0_7handlerEEERKNS0_6detail13code_locationE
36543655
_ZN2cl4sycl5queue11submit_implESt8functionIFvRNS0_7handlerEEES1_RKNS0_6detail13code_locationE
@@ -3883,7 +3884,7 @@ _ZN2cl4sycl7contextC2ERKSt6vectorINS0_6deviceESaIS3_EERKNS0_13property_listE
38833884
_ZN2cl4sycl7contextC2ERKSt6vectorINS0_6deviceESaIS3_EESt8functionIFvNS0_14exception_listEEERKNS0_13property_listE
38843885
_ZN2cl4sycl7contextC2ERKSt8functionIFvNS0_14exception_listEEERKNS0_13property_listE
38853886
_ZN2cl4sycl7contextC2ESt10shared_ptrINS0_6detail12context_implEE
3886-
_ZN2cl4sycl7handler10mem_adviseEPKvm14_pi_mem_advice
3887+
_ZN2cl4sycl7handler10mem_adviseEPKvmi
38873888
_ZN2cl4sycl7handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmb
38883889
_ZN2cl4sycl7handler10processArgEPvRKNS0_6detail19kernel_param_kind_tEimRmbb
38893890
_ZN2cl4sycl7handler13getKernelNameB5cxx11Ev

0 commit comments

Comments
 (0)