Skip to content

Commit d8d0d5f

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents d869f5a + c90b361 commit d8d0d5f

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,7 @@ bool Driver::checkForOffloadStaticLib(Compilation &C,
27832783
!Args.hasArg(options::OPT_fopenmp_targets_EQ))
27842784
return false;
27852785

2786-
// Right off the bat, assume the presense of -foffload-static-lib means
2786+
// Right off the bat, assume the presence of -foffload-static-lib means
27872787
// the need to perform linking steps for fat static archive offloading.
27882788
// TODO: remove when -foffload-static-lib support is dropped.
27892789
if (Args.hasArg(options::OPT_offload_lib_Group))

sycl/source/detail/config.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ CONFIG(SYCL_BE, 16, __SYCL_BE)
1717
CONFIG(SYCL_PI_TRACE, 16, __SYCL_PI_TRACE)
1818
CONFIG(SYCL_DEVICELIB_NO_FALLBACK, 1, __SYCL_DEVICELIB_NO_FALLBACK)
1919
CONFIG(SYCL_DEVICE_FILTER, 1024, __SYCL_DEVICE_FILTER)
20+
CONFIG(SYCL_PROGRAM_LINK_OPTIONS, 64, __SYCL_PROGRAM_LINK_OPTIONS)
21+
CONFIG(SYCL_PROGRAM_COMPILE_OPTIONS, 64, __SYCL_PROGRAM_COMPILE_OPTIONS)

sycl/source/detail/program_impl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <CL/sycl/detail/pi.h>
1212
#include <CL/sycl/kernel.hpp>
1313
#include <CL/sycl/property_list.hpp>
14+
#include <detail/config.hpp>
1415
#include <detail/kernel_impl.hpp>
1516
#include <detail/program_impl.hpp>
1617
#include <detail/spec_constant_impl.hpp>
@@ -291,9 +292,13 @@ void program_impl::link(string_class LinkOptions) {
291292
check_device_feature_support<info::device::is_linker_available>(MDevices);
292293
vector_class<RT::PiDevice> Devices(get_pi_devices());
293294
const detail::plugin &Plugin = getPlugin();
295+
const char *LinkOpts = SYCLConfig<SYCL_PROGRAM_LINK_OPTIONS>::get();
296+
if (!LinkOpts) {
297+
LinkOpts = LinkOptions.c_str();
298+
}
294299
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramLink>(
295-
MContext->getHandleRef(), Devices.size(), Devices.data(),
296-
LinkOptions.c_str(), 1, &MProgram, nullptr, nullptr, &MProgram);
300+
MContext->getHandleRef(), Devices.size(), Devices.data(), LinkOpts,
301+
/*num_input_programs*/ 1, &MProgram, nullptr, nullptr, &MProgram);
297302
Plugin.checkPiResult<compile_program_error>(Err);
298303
MLinkOptions = LinkOptions;
299304
MBuildOptions = LinkOptions;
@@ -363,8 +368,12 @@ void program_impl::compile(const string_class &Options) {
363368
check_device_feature_support<info::device::is_compiler_available>(MDevices);
364369
vector_class<RT::PiDevice> Devices(get_pi_devices());
365370
const detail::plugin &Plugin = getPlugin();
371+
const char *CompileOpts = SYCLConfig<SYCL_PROGRAM_COMPILE_OPTIONS>::get();
372+
if (!CompileOpts) {
373+
CompileOpts = Options.c_str();
374+
}
366375
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramCompile>(
367-
MProgram, Devices.size(), Devices.data(), Options.c_str(), 0, nullptr,
376+
MProgram, Devices.size(), Devices.data(), CompileOpts, 0, nullptr,
368377
nullptr, nullptr, nullptr);
369378

370379
if (Err != PI_SUCCESS) {

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
355355

356356
if ((Req->MAccessMode == access::mode::discard_write) ||
357357
(Req->MAccessMode == access::mode::discard_read_write)) {
358+
Record->MCurContext = Queue->getContextImplPtr();
358359
return nullptr;
359360
} else {
360361
// Full copy of buffer is needed to avoid loss of data that may be caused

sycl/unittests/scheduler/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ add_sycl_unittest(SchedulerTests OBJECT
88
WaitAfterCleanup.cpp
99
LinkedAllocaDependencies.cpp
1010
LeavesCollection.cpp
11-
NoUnifiedHostMemory.cpp
11+
NoHostUnifiedMemory.cpp
1212
StreamInitDependencyOnHost.cpp
1313
InOrderQueueDeps.cpp
1414
utils.cpp

sycl/unittests/scheduler/NoUnifiedHostMemory.cpp renamed to sycl/unittests/scheduler/NoHostUnifiedMemory.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//==----------- NoUnifiedHostMemory.cpp --- Scheduler unit tests -----------==//
1+
//==----------- NoHostUnifiedMemory.cpp --- Scheduler unit tests -----------==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -62,7 +62,7 @@ static pi_result redefinedEnqueueMemBufferWriteRect(
6262

6363
static pi_result redefinedMemRelease(pi_mem mem) { return PI_SUCCESS; }
6464

65-
TEST_F(SchedulerTest, NoUnifiedHostMemory) {
65+
TEST_F(SchedulerTest, NoHostUnifiedMemory) {
6666
platform Plt{default_selector()};
6767
if (Plt.is_host()) {
6868
std::cout << "Not run due to host-only environment\n";
@@ -144,4 +144,26 @@ TEST_F(SchedulerTest, NoUnifiedHostMemory) {
144144
detail::Command *MemoryMove = MS.insertMemoryMove(Record, &Req, QImpl);
145145
EXPECT_EQ(MemoryMove->getType(), detail::Command::COPY_MEMORY);
146146
}
147+
// Check that memory movement operations work correctly with/after discard
148+
// access modes.
149+
{
150+
int val;
151+
buffer<int, 1> Buf(&val, range<1>(1));
152+
detail::Requirement Req = getMockRequirement(Buf);
153+
ExpectedMemObjFlags = PI_MEM_FLAGS_ACCESS_RW | PI_MEM_FLAGS_HOST_PTR_COPY;
154+
155+
detail::Requirement DiscardReq = getMockRequirement(Buf);
156+
DiscardReq.MAccessMode = access::mode::discard_read_write;
157+
158+
detail::MemObjRecord *Record = MS.getOrInsertMemObjRecord(QImpl, &Req);
159+
MS.getOrCreateAllocaForReq(Record, &Req, QImpl);
160+
MS.getOrCreateAllocaForReq(Record, &Req, DefaultHostQueue);
161+
162+
// Memory movement operations should be omitted for discard access modes.
163+
detail::Command *MemoryMove =
164+
MS.insertMemoryMove(Record, &DiscardReq, DefaultHostQueue);
165+
EXPECT_EQ(MemoryMove, nullptr);
166+
// The current context for the record should still be modified.
167+
EXPECT_EQ(Record->MCurContext, DefaultHostQueue->getContextImplPtr());
168+
}
147169
}

0 commit comments

Comments
 (0)