This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL][ESIMD] Add test for support of compile time hardware dispatch #1486
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d752368
Add hardware dispatch test
fineg74 eb83e3b
update test
fineg74 96f9b8e
Update test configuration
fineg74 11913e4
Modify test
fineg74 4abd4cf
Fix the test
fineg74 dddca36
Fix the test
fineg74 c80b575
Add success message
fineg74 65d1d66
Move the file to SYCL/ESIMD folder
fineg74 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,81 @@ | ||
//==---------------- hardware_dispatch.cpp - ESIMD hardware dispatch test -==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// REQUIRES: gpu | ||
// UNSUPPORTED: cuda || hip | ||
// UNSUPPORTED: esimd_emulator | ||
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_bdw %s -o %t.out | ||
// RUN: %t.out | ||
// TODO: remove XFAIL when the fix in GPU RT is pulled into CI | ||
// XFAIL: * | ||
// This is basic test to test hardware dispatch functionality with ESIMD. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/ext/intel/esimd/simd.hpp> | ||
#include <sycl/ext/oneapi/experimental/device_architecture.hpp> | ||
#include <sycl/sycl.hpp> | ||
#include <vector> | ||
|
||
using shared_allocator = sycl::usm_allocator<int32_t, sycl::usm::alloc::shared>; | ||
using shared_vector = std::vector<int32_t, shared_allocator>; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
int main() { | ||
sycl::queue q; | ||
shared_allocator allocator(q); | ||
|
||
shared_vector vec(4, allocator); | ||
{ | ||
q.submit([&](sycl::handler &cgh) { | ||
int *output_ptr = vec.data(); | ||
cgh.single_task<class test1>([=]() SYCL_ESIMD_KERNEL { | ||
simd<int, 4> result; | ||
|
||
// test if_architecture_is | ||
sycl::ext::oneapi::experimental::if_architecture_is< | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_bdw>( | ||
[&]() { result[0] = 1; }) | ||
.otherwise([&]() { result[0] = 0; }); | ||
|
||
// test else_if_architecture_is | ||
sycl::ext::oneapi::experimental::if_architecture_is< | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_dg1>( | ||
[&]() { result[1] = 0; }) | ||
.else_if_architecture_is< | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_bdw>( | ||
[&]() { result[1] = 2; }) | ||
.otherwise([&]() { result[1] = 0; }); | ||
|
||
// test otherwise | ||
sycl::ext::oneapi::experimental::if_architecture_is< | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_dg1>( | ||
[&]() { result[2] = 0; }) | ||
.otherwise([&]() { result[2] = 3; }); | ||
|
||
// test more than one architecture template parameter is passed to | ||
// if_architecture_is | ||
sycl::ext::oneapi::experimental::if_architecture_is< | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_dg1, | ||
sycl::ext::oneapi::experimental::architecture::intel_gpu_bdw>( | ||
[&]() { result[3] = 4; }) | ||
.otherwise([&]() { result[3] = 0; }); | ||
result.copy_to(output_ptr); | ||
}); | ||
}); | ||
} | ||
q.wait(); | ||
|
||
for (int i = 0; i < 4; ++i) { | ||
if (vec[i] != i + 1) { | ||
std::cout << "Test failed for index " << i << std::endl; | ||
return 1; | ||
} | ||
} | ||
std::cout << "Pass" << std::endl; | ||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.