Skip to content

Commit 4b42464

Browse files
committed
Respond to comments
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent eadc69e commit 4b42464

File tree

8 files changed

+14
-29
lines changed

8 files changed

+14
-29
lines changed

sycl/source/detail/global_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void GlobalHandler::registerDefaultContextReleaseHandler() {
118118

119119
// Note: Split from shutdown so it is available to the unittests for ensuring
120120
// that the mock plugin is the lone plugin.
121-
void GlobalHandler::clearPlugins() {
121+
void GlobalHandler::unloadPlugins() {
122122
// Call to GlobalHandler::instance().getPlugins() initializes plugins. If
123123
// user application has loaded SYCL runtime, and never called any APIs,
124124
// there's no need to load and unload plugins.
@@ -153,7 +153,7 @@ void shutdown() {
153153
GlobalHandler::instance().MProgramManager.Inst.reset(nullptr);
154154

155155
// Clear the plugins and reset the instance if it was there.
156-
GlobalHandler::instance().clearPlugins();
156+
GlobalHandler::instance().unloadPlugins();
157157
if (GlobalHandler::instance().MPlugins.Inst)
158158
GlobalHandler::instance().MPlugins.Inst.reset(nullptr);
159159

sycl/source/detail/global_handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class GlobalHandler {
7171

7272
static void registerDefaultContextReleaseHandler();
7373

74-
void clearPlugins();
74+
void unloadPlugins();
7575

7676
private:
7777
friend void releaseDefaultContexts();

sycl/source/detail/posix_pi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ void *loadOsLibrary(const std::string &PluginPath) {
3030
}
3131

3232
int unloadOsLibrary(void *Library) {
33+
// The mock plugin does not have an associated library, so we allow nullptr
34+
// here to avoid it trying to free a non-existent library.
3335
if (!Library)
3436
return 0;
3537
return dlclose(Library);

sycl/source/detail/windows_pi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ void *loadOsLibrary(const std::string &PluginPath) {
4141
}
4242

4343
int unloadOsLibrary(void *Library) {
44+
// The mock plugin does not have an associated library, so we allow nullptr
45+
// here to avoid it trying to free a non-existent library.
4446
if (!Library)
4547
return 1;
4648
return (int)FreeLibrary((HMODULE)Library);

sycl/unittests/assert/assert.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ void ParentProcess(int ChildPID, int ChildStdErrFD) {
527527
#endif // _WIN32
528528

529529
TEST(Assert, TestPositive) {
530+
// Ensure that the mock plugin is initialized before spawning work. Since the
531+
// test needs no redefinitions we do not need to create a PiMock instance, but
532+
// the mock plugin is still needed to have a valid platform available.
530533
sycl::unittest::PiMock::EnsureMockPluginInitialized();
531534

532535
#ifndef _WIN32

sycl/unittests/helpers/PiMock.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class PiMock {
187187
// Ensure that the other plugins are initialized so we can unload them.
188188
// This makes sure that the mock plugin is the only available plugin.
189189
detail::pi::initialize();
190-
detail::GlobalHandler::instance().clearPlugins();
190+
detail::GlobalHandler::instance().unloadPlugins();
191191
std::vector<detail::plugin> &Plugins =
192192
detail::GlobalHandler::instance().getPlugins();
193193

sycl/unittests/kernel-and-program/Cache.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ struct TestCtx {
9191

9292
std::unique_ptr<TestCtx> globalCtx;
9393

94-
static pi_result redefinedProgramCreateWithSource(pi_context context,
95-
pi_uint32 count,
96-
const char **strings,
97-
const size_t *lengths,
98-
pi_program *ret_program) {
99-
*ret_program = reinterpret_cast<pi_program>(1);
100-
return PI_SUCCESS;
101-
}
102-
10394
static pi_result redefinedKernelGetInfo(pi_kernel kernel,
10495
pi_kernel_info param_name,
10596
size_t param_value_size,
@@ -113,25 +104,13 @@ static pi_result redefinedKernelGetInfo(pi_kernel kernel,
113104
return PI_SUCCESS;
114105
}
115106

116-
static pi_result redefinedKernelCreate(pi_program program,
117-
const char *kernel_name,
118-
pi_kernel *ret_kernel) {
119-
return PI_SUCCESS;
120-
}
121-
122-
static pi_result redefinedKernelRelease(pi_kernel kernel) { return PI_SUCCESS; }
123-
124107
class KernelAndProgramCacheTest : public ::testing::Test {
125108
public:
126109
KernelAndProgramCacheTest() : Mock{}, Plt{Mock.getPlatform()} {}
127110

128111
protected:
129112
void SetUp() override {
130-
Mock.redefine<detail::PiApiKind::piclProgramCreateWithSource>(
131-
redefinedProgramCreateWithSource);
132113
Mock.redefine<detail::PiApiKind::piKernelGetInfo>(redefinedKernelGetInfo);
133-
Mock.redefine<detail::PiApiKind::piKernelCreate>(redefinedKernelCreate);
134-
Mock.redefine<detail::PiApiKind::piKernelRelease>(redefinedKernelRelease);
135114
}
136115

137116
protected:

sycl/unittests/scheduler/QueueFlushing.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ TEST_F(SchedulerTest, QueueFlushing) {
140140
redefinedEnqueueMemBufferFill);
141141

142142
context Ctx{Plt};
143-
default_selector Selector;
144-
queue QueueA{Ctx, Selector};
143+
queue QueueA{Ctx, default_selector_v};
145144
detail::QueueImplPtr QueueImplA = detail::getSyclObjImpl(QueueA);
146-
queue QueueB{Ctx, Selector};
145+
queue QueueB{Ctx, default_selector_v};
147146
detail::QueueImplPtr QueueImplB = detail::getSyclObjImpl(QueueB);
148147
ExpectedDepQueue = QueueImplB->getHandleRef();
149148

@@ -214,7 +213,7 @@ TEST_F(SchedulerTest, QueueFlushing) {
214213
access::mode::read_write};
215214
detail::EventImplPtr DepEvent;
216215
{
217-
queue TempQueue{Ctx, Selector};
216+
queue TempQueue{Ctx, default_selector_v};
218217
detail::QueueImplPtr TempQueueImpl = detail::getSyclObjImpl(TempQueue);
219218
DepEvent.reset(new detail::event_impl(TempQueueImpl));
220219
DepEvent->setContextImpl(TempQueueImpl->getContextImplPtr());

0 commit comments

Comments
 (0)