Skip to content

Commit 88578bb

Browse files
committed
[SYCL][NFC] Return adapter by ref in KernelProgramCache
1 parent 5e56cdf commit 88578bb

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

sycl/source/detail/kernel_program_cache.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <detail/adapter_impl.hpp>
109
#include <detail/context_impl.hpp>
1110
#include <detail/kernel_program_cache.hpp>
1211

1312
namespace sycl {
1413
inline namespace _V1 {
1514
namespace detail {
16-
const AdapterPtr &KernelProgramCache::getAdapter() {
17-
return MParentContext->getAdapter();
15+
const adapter_impl &KernelProgramCache::getAdapter() {
16+
return *(MParentContext->getAdapter());
1817
}
1918

2019
ur_context_handle_t KernelProgramCache::getURContext() const {

sycl/source/detail/kernel_program_cache.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ class KernelProgramCache {
112112
};
113113

114114
struct ProgramBuildResult : public BuildResult<ur_program_handle_t> {
115-
AdapterPtr MAdapter;
116-
ProgramBuildResult(const AdapterPtr &AAdapter) : MAdapter(AAdapter) {
115+
const adapter_impl &MAdapter;
116+
ProgramBuildResult(const adapter_impl &AAdapter) : MAdapter(AAdapter) {
117117
Val = nullptr;
118118
}
119-
ProgramBuildResult(const AdapterPtr &AAdapter, BuildState InitialState)
119+
ProgramBuildResult(const adapter_impl &AAdapter, BuildState InitialState)
120120
: MAdapter(AAdapter) {
121121
Val = nullptr;
122122
this->State.store(InitialState);
@@ -125,8 +125,8 @@ class KernelProgramCache {
125125
try {
126126
if (Val) {
127127
ur_result_t Err =
128-
MAdapter->call_nocheck<UrApiKind::urProgramRelease>(Val);
129-
__SYCL_CHECK_UR_CODE_NO_EXC(Err, MAdapter->getBackend());
128+
MAdapter.call_nocheck<UrApiKind::urProgramRelease>(Val);
129+
__SYCL_CHECK_UR_CODE_NO_EXC(Err, MAdapter.getBackend());
130130
}
131131
} catch (std::exception &e) {
132132
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~ProgramBuildResult",
@@ -198,16 +198,16 @@ class KernelProgramCache {
198198
using KernelArgMaskPairT =
199199
std::pair<ur_kernel_handle_t, const KernelArgMask *>;
200200
struct KernelBuildResult : public BuildResult<KernelArgMaskPairT> {
201-
AdapterPtr MAdapter;
202-
KernelBuildResult(const AdapterPtr &AAdapter) : MAdapter(AAdapter) {
201+
const adapter_impl &MAdapter;
202+
KernelBuildResult(const adapter_impl &AAdapter) : MAdapter(AAdapter) {
203203
Val.first = nullptr;
204204
}
205205
~KernelBuildResult() {
206206
try {
207207
if (Val.first) {
208208
ur_result_t Err =
209-
MAdapter->call_nocheck<UrApiKind::urKernelRelease>(Val.first);
210-
__SYCL_CHECK_UR_CODE_NO_EXC(Err, MAdapter->getBackend());
209+
MAdapter.call_nocheck<UrApiKind::urKernelRelease>(Val.first);
210+
__SYCL_CHECK_UR_CODE_NO_EXC(Err, MAdapter.getBackend());
211211
}
212212
} catch (std::exception &e) {
213213
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~KernelBuildResult", e);
@@ -668,18 +668,18 @@ class KernelProgramCache {
668668
// Store size of the program and check if we need to evict some entries.
669669
// Get Size of the program.
670670
size_t ProgramSize = 0;
671-
auto Adapter = getAdapter();
671+
const adapter_impl &Adapter = getAdapter();
672672

673673
try {
674674
// Get number of devices this program was built for.
675675
unsigned int DeviceNum = 0;
676-
Adapter->call<UrApiKind::urProgramGetInfo>(
676+
Adapter.call<UrApiKind::urProgramGetInfo>(
677677
Program, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum,
678678
nullptr);
679679

680680
// Get binary sizes for each device.
681681
std::vector<size_t> BinarySizes(DeviceNum);
682-
Adapter->call<UrApiKind::urProgramGetInfo>(
682+
Adapter.call<UrApiKind::urProgramGetInfo>(
683683
Program, UR_PROGRAM_INFO_BINARY_SIZES,
684684
sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr);
685685

@@ -868,7 +868,7 @@ class KernelProgramCache {
868868

869869
friend class ::MockKernelProgramCache;
870870

871-
const AdapterPtr &getAdapter();
871+
const adapter_impl &getAdapter();
872872
ur_context_handle_t getURContext() const;
873873
};
874874
} // namespace detail

0 commit comments

Comments
 (0)