-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][ESIMD]Limit bfloat16 operators to scalars to enable operations with simd vectors #12089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
22dcb20
Limit bfloat16 operators to scalars to enable operations with simd ve…
fineg74 7322f79
Update the test
fineg74 89aea1f
Fix clang-format
fineg74 ba7b68f
Fix clang-format issues
fineg74 4f1b78d
Address PR comments and split the test so it can be run on different …
fineg74 19dcb31
Merge remote-tracking branch 'origin/sycl' into bfloat16Operator
fineg74 ca3ad03
Update implementation of operators for bfloat16 in a similar way it i…
fineg74 7880dfe
Fix incorrect implementation of operators
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
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
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
100 changes: 100 additions & 0 deletions
100
sycl/test-e2e/ESIMD/regression/bfloat16_vector_plus_scalar.cpp
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,100 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
//==- bfloat16_vector_plus_scalar.cpp - Test for bfloat16 operators ------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include "../esimd_test_utils.hpp" | ||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
using namespace sycl::ext::intel::experimental::esimd; | ||
|
||
template <typename T> ESIMD_NOINLINE bool test(queue Q) { | ||
std::cout << "Testing T=" << esimd_test::type_name<T>() << "...\n"; | ||
|
||
constexpr int N = 8; | ||
|
||
constexpr int NumOps = 4; | ||
constexpr int CSize = NumOps * N; | ||
|
||
T *Mem = malloc_shared<T>(CSize, Q); | ||
T TOne = static_cast<T>(1); | ||
T TTen = static_cast<T>(10); | ||
|
||
Q.single_task([=]() SYCL_ESIMD_KERNEL { | ||
{ | ||
simd<T, N> Vec(TOne); | ||
Vec = Vec + TTen; | ||
Vec.copy_to(Mem); | ||
} | ||
{ | ||
simd<T, N> Vec(TOne); | ||
Vec = Vec - TTen; | ||
Vec.copy_to(Mem + N); | ||
} | ||
{ | ||
simd<T, N> Vec(TOne); | ||
Vec = Vec * TTen; | ||
Vec.copy_to(Mem + 2 * N); | ||
} | ||
{ | ||
simd<T, N> Vec(TOne); | ||
Vec = Vec / TTen; | ||
Vec.copy_to(Mem + 3 * N); | ||
} | ||
}).wait(); | ||
|
||
bool ReturnValue = true; | ||
for (int i = 0; i < N; ++i) { | ||
if (Mem[i] != TOne + TTen) { | ||
ReturnValue = false; | ||
break; | ||
} | ||
if (Mem[i + N] != TOne - TTen) { | ||
ReturnValue = false; | ||
break; | ||
} | ||
if (Mem[i + 2 * N] != TOne * TTen) { | ||
ReturnValue = false; | ||
break; | ||
} | ||
if (!((Mem[i + 3 * N] == (TOne / TTen)) || | ||
(std::abs((double)(Mem[i + 3 * N] - (TOne / TTen)) / | ||
(double)(TOne / TTen)) <= 0.001))) { | ||
ReturnValue = false; | ||
break; | ||
} | ||
} | ||
|
||
free(Mem, Q); | ||
return ReturnValue; | ||
} | ||
|
||
int main() { | ||
queue Q; | ||
esimd_test::printTestLabel(Q); | ||
|
||
bool SupportsHalf = Q.get_device().has(aspect::fp16); | ||
|
||
bool Passed = true; | ||
Passed &= test<int>(Q); | ||
Passed &= test<float>(Q); | ||
if (SupportsHalf) { | ||
Passed &= test<sycl::half>(Q); | ||
} | ||
#ifdef USE_BF16 | ||
Passed &= test<sycl::ext::oneapi::bfloat16>(Q); | ||
#endif | ||
#ifdef USE_TF32 | ||
Passed &= test<sycl::ext::intel::experimental::esimd::tfloat32>(Q); | ||
#endif | ||
std::cout << (Passed ? "Passed\n" : "FAILED\n"); | ||
return Passed ? 0 : 1; | ||
} |
14 changes: 14 additions & 0 deletions
14
sycl/test-e2e/ESIMD/regression/bfloat16_vector_plus_scalar_pvc.cpp
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,14 @@ | ||
//==- bfloat16_vector_plus_scalar_pvc.cpp - Test for bfloat16 operators -==// | ||
// | ||
// 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-intel-pvc | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
#define USE_BF16 | ||
#define USE_TF32 | ||
#include "bfloat16_vector_plus_scalar.cpp" |
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.