-
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.
Merge pull request #1233 from callumfare/callum/cts_usm_pt1
[CTS] Add more USM testing
- Loading branch information
Showing
9 changed files
with
261 additions
and
23 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,68 @@ | ||
// 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; | ||
}; | ||
|
||
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
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