-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Expand USMMemcpy2D testing to test all USM allocation types * Add USM linked list kernel execution test The linked list test is based on USM/smemll.cpp from the SYCL-E2E tests and checks that USM allocations are actually usable from a kernel.
- Loading branch information
1 parent
2d42d77
commit 31a5794
Showing
8 changed files
with
257 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
|
||
int numNodes = 4; | ||
|
||
struct Node { | ||
Node() : pNext(nullptr), Num(0xDEADBEEF) {} | ||
|
||
Node *pNext; | ||
uint32_t Num; | ||
}; | ||
|
||
class foo; | ||
int main() { | ||
queue q; | ||
auto dev = q.get_device(); | ||
auto ctxt = q.get_context(); | ||
|
||
if (!dev.get_info<info::device::usm_shared_allocations>()) { | ||
return 0; | ||
} | ||
|
||
Node *s_head = | ||
(Node *)aligned_alloc_shared(alignof(Node), sizeof(Node), dev, ctxt); | ||
if (s_head == nullptr) { | ||
return -1; | ||
} | ||
Node *s_cur = s_head; | ||
|
||
for (int i = 0; i < numNodes; i++) { | ||
s_cur->Num = i * 2; | ||
|
||
if (i != (numNodes - 1)) { | ||
s_cur->pNext = (Node *)aligned_alloc_shared( | ||
alignof(Node), sizeof(Node), dev, ctxt); | ||
} else { | ||
s_cur->pNext = nullptr; | ||
} | ||
|
||
s_cur = s_cur->pNext; | ||
} | ||
|
||
auto e1 = q.submit([=](handler &cgh) { | ||
cgh.single_task<class linkedlist>([=]() { | ||
Node *pHead = s_head; | ||
while (pHead) { | ||
pHead->Num = pHead->Num * 2 + 1; | ||
pHead = pHead->pNext; | ||
} | ||
}); | ||
}); | ||
|
||
e1.wait(); | ||
|
||
s_cur = s_head; | ||
for (int i = 0; i < numNodes; i++) { | ||
Node *old = s_cur; | ||
s_cur = s_cur->pNext; | ||
free(old, ctxt); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters