Skip to content

Commit f391125

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents ca1acf9 + da6d1dc commit f391125

File tree

5 files changed

+62
-22
lines changed

5 files changed

+62
-22
lines changed

sycl/include/CL/sycl/buffer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class buffer {
170170
const property_list &propList = {})
171171
: Range(range<1>(container.size())) {
172172
impl = std::make_shared<detail::buffer_impl>(
173-
container.data(), container.data() + container.size(),
174-
get_count() * sizeof(T), detail::getNextPowerOfTwo(sizeof(T)), propList,
173+
container.data(), get_count() * sizeof(T),
174+
detail::getNextPowerOfTwo(sizeof(T)), propList,
175175
make_unique_ptr<detail::SYCLMemObjAllocatorHolder<AllocatorT>>(
176176
allocator));
177177
}

sycl/source/detail/scheduler/commands.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,15 @@ class Command {
219219
bool MIsBlockable = false;
220220
/// Counts the number of memory objects this command is a leaf for.
221221
unsigned MLeafCounter = 0;
222-
/// Used for marking the node as visited during graph traversal.
223-
bool MVisited = false;
222+
223+
struct Marks {
224+
/// Used for marking the node as visited during graph traversal.
225+
bool MVisited = false;
226+
/// Used for marking the node for deletion during cleanup.
227+
bool MToBeDeleted = false;
228+
};
229+
/// Used for marking the node during graph traversal.
230+
Marks MMarks;
224231

225232
enum class BlockReason : int { HostAccessor = 0, HostTask };
226233

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,26 @@ Scheduler::GraphBuilder::GraphBuilder() {
9393
}
9494

9595
static bool markNodeAsVisited(Command *Cmd, std::vector<Command *> &Visited) {
96-
if (Cmd->MVisited)
96+
if (Cmd->MMarks.MVisited)
9797
return false;
98-
Cmd->MVisited = true;
98+
Cmd->MMarks.MVisited = true;
9999
Visited.push_back(Cmd);
100100
return true;
101101
}
102102

103103
static void unmarkVisitedNodes(std::vector<Command *> &Visited) {
104104
for (Command *Cmd : Visited)
105-
Cmd->MVisited = false;
105+
Cmd->MMarks.MVisited = false;
106+
}
107+
108+
static void handleVisitedNodes(std::vector<Command *> &Visited) {
109+
for (Command *Cmd : Visited) {
110+
if (Cmd->MMarks.MToBeDeleted) {
111+
Cmd->getEvent()->setCommand(nullptr);
112+
delete Cmd;
113+
} else
114+
Cmd->MMarks.MVisited = false;
115+
}
106116
}
107117

108118
static void printDotRecursive(std::fstream &Stream,
@@ -825,7 +835,6 @@ void Scheduler::GraphBuilder::cleanupCommandsForRecord(MemObjRecord *Record) {
825835

826836
std::queue<Command *> ToVisit;
827837
std::vector<Command *> Visited;
828-
std::vector<Command *> CmdsToDelete;
829838
// First, mark all allocas for deletion and their direct users for traversal
830839
// Dependencies of the users will be cleaned up during the traversal
831840
for (Command *AllocaCmd : AllocaCommands) {
@@ -839,7 +848,7 @@ void Scheduler::GraphBuilder::cleanupCommandsForRecord(MemObjRecord *Record) {
839848
else
840849
markNodeAsVisited(UserCmd, Visited);
841850

842-
CmdsToDelete.push_back(AllocaCmd);
851+
AllocaCmd->MMarks.MToBeDeleted = true;
843852
// These commands will be deleted later, clear users now to avoid
844853
// updating them during edge removal
845854
AllocaCmd->MUsers.clear();
@@ -851,7 +860,7 @@ void Scheduler::GraphBuilder::cleanupCommandsForRecord(MemObjRecord *Record) {
851860
AllocaCommandBase *LinkedCmd = AllocaCmd->MLinkedAllocaCmd;
852861

853862
if (LinkedCmd) {
854-
assert(LinkedCmd->MVisited);
863+
assert(LinkedCmd->MMarks.MVisited);
855864

856865
for (DepDesc &Dep : AllocaCmd->MDeps)
857866
if (Dep.MDepCommand)
@@ -896,17 +905,12 @@ void Scheduler::GraphBuilder::cleanupCommandsForRecord(MemObjRecord *Record) {
896905
// If all dependencies have been removed this way, mark the command for
897906
// deletion
898907
if (Cmd->MDeps.empty()) {
899-
CmdsToDelete.push_back(Cmd);
908+
Cmd->MMarks.MToBeDeleted = true;
900909
Cmd->MUsers.clear();
901910
}
902911
}
903912

904-
unmarkVisitedNodes(Visited);
905-
906-
for (Command *Cmd : CmdsToDelete) {
907-
Cmd->getEvent()->setCommand(nullptr);
908-
delete Cmd;
909-
}
913+
handleVisitedNodes(Visited);
910914
}
911915

912916
void Scheduler::GraphBuilder::cleanupFinishedCommands(Command *FinishedCmd) {
@@ -948,12 +952,10 @@ void Scheduler::GraphBuilder::cleanupFinishedCommands(Command *FinishedCmd) {
948952
Command *DepCmd = Dep.MDepCommand;
949953
DepCmd->MUsers.erase(Cmd);
950954
}
951-
Cmd->getEvent()->setCommand(nullptr);
952955

953-
Visited.pop_back();
954-
delete Cmd;
956+
Cmd->MMarks.MToBeDeleted = true;
955957
}
956-
unmarkVisitedNodes(Visited);
958+
handleVisitedNodes(Visited);
957959
}
958960

959961
void Scheduler::GraphBuilder::removeRecordForMemObj(SYCLMemObjI *MemObject) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clangxx %s -std=c++17 -o %t1.out -lsycl -I %sycl_include
2+
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
3+
// RUN: %clangxx -std=c++17 -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
4+
// RUN: env SYCL_DEVICE_TYPE=HOST %t2.out
5+
// RUN: %CPU_RUN_PLACEHOLDER %t2.out
6+
// RUN: %GPU_RUN_PLACEHOLDER %t2.out
7+
// RUN: %ACC_RUN_PLACEHOLDER %t2.out
8+
9+
#include <CL/sycl.hpp>
10+
11+
using namespace cl::sycl;
12+
13+
int main() {
14+
// buffer created from contiguous container copies back
15+
{
16+
constexpr int num = 10;
17+
std::vector<int> out_data(num, -1);
18+
{
19+
buffer A(out_data);
20+
queue Q;
21+
Q.submit([&](handler &h) {
22+
auto out = A.get_access<access::mode::write>(h);
23+
h.parallel_for<class containerBuffer>(A.get_range(),
24+
[out](id<1> i) { out[i] = 1; });
25+
});
26+
} //~buffer
27+
for (int i = 0; i < num; i++)
28+
assert(out_data[i] == 1);
29+
}
30+
}

sycl/test/host-interop-task/interop-task.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
5-
// USUPPORTED: level0, cuda
5+
// UNSUPPORTED: level0, cuda
66
// REQUIRES: opencl
7+
// REQUIRES: TEMPORARY_DISABLED
78

89
#include <CL/sycl.hpp>
910
#include <CL/sycl/backend/opencl.hpp>

0 commit comments

Comments
 (0)