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] Test corrections after moving bfloat16 support out of experimental status. #1129
Merged
Merged
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
f6bb8a3
[SYCL] Localize variables declared in inline asms.
rdeodhar bb523e8
[SYCL] Test for disabling range rounding.
rdeodhar d2d1da9
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar cda63e1
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 69b6a46
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar d49e0f7
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 9af3a0d
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 1e7b325
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar acd2770
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar a9b4c23
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 49d9fca
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8d3654d
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 47f7ef9
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 03a870a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 23b318e
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 7dcf812
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 37b6097
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 84b320a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 2659c72
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar de6173b
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar fb1b230
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 45b3951
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar a4f01f3
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar d69e8a1
[SYCL] Adjustments to tests to account for moving bfloat16 support ou…
rdeodhar 8da975e
Formatting change.
rdeodhar 9e34353
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar d7b1b15
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar aa5f69c
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 0717d52
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 29452c0
Corrections for bfloat16 moved out of experimental.
rdeodhar b2ade7a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar bef81ca
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 63b05d1
Correct test to run on multiple root devices.
rdeodhar 17ad74e
Merge branch 'intel' of https://github.com/rdeodhar/llvm-test-suite i…
rdeodhar 1ba36eb
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar cb629ff
Removed test correction since test is now disabled.
rdeodhar 6b0e62b
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 30b81b1
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar df36f2d
Modifications and additions to bfloat16 tests.
rdeodhar 5bf2384
Formatting change.
rdeodhar e9683a1
Formatting change.
rdeodhar e7a9191
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 603d4b6
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 23077db
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar c066b3a
Enable bfloat16 test on GPU only.
rdeodhar 44e492b
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 3028e7e
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar b0c0848
Reenable bfloat16 test on CPU.
rdeodhar 6cba127
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 64e4bbd
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 7b0c9a2
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8f51bc2
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 49a522a
Corrected test to run on host and device.
rdeodhar fcd6c3e
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 7e84648
Update SYCL/BFloat16/bfloat16_type.cpp
rdeodhar c60ab99
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 314719e
Merge branch 'l30' of https://github.com/rdeodhar/llvm-test-suite int…
rdeodhar 3bb080c
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 2b77ff2
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar dfc9a67
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar e021ad7
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar af254b3
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8f492d6
Added test for use of fallback bfloat16 library.
rdeodhar 4805061
Formatting change
rdeodhar 33c7d2b
Enhanced the bfloat16 fallback test.
rdeodhar 21dcd20
Formatting change.
rdeodhar cbfe491
Adjusted bfloat16 aspect.
rdeodhar 3721b97
Changes to test to set up required environment.
rdeodhar 44c6ccb
Adjustment to test.
rdeodhar c7d9386
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar c3155bf
Test adjustment.
rdeodhar f2edee8
Reenabled some tests with specific GPU requirement.
rdeodhar 9634b60
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 6ee676a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 2c6f4ce
Changes for bfloat16 moved out of experimental.
rdeodhar 43768d8
Aspect bfloat16 has been removed.
rdeodhar 5ba6d74
Aspect bfloat16 has been replaced by bfloat16_math_functions.
rdeodhar ccc85df
Check aspect fp16 before using sycl::half.
rdeodhar 3b60cb1
Account for lack of fp16 support on some devices.
rdeodhar 1b0d6f2
Reduce expected precision of bfloat16 calculations.
rdeodhar 0bc6438
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8d9f34f
Adjustments for bfloat16 header.
rdeodhar 8792d0a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar f1975c5
Test adjustment.
rdeodhar 80c3468
Replace double constants with float.
rdeodhar db0a1bc
Replace double constants with float.
rdeodhar f6c14e0
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 33a36ce
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8511e52
Fix test to return 0 from main.
rdeodhar 6564c68
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 8d44444
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 6928b2a
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
rdeodhar 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// UNSUPPORTED: hip | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-device-code-split=per_kernel %s -o %t.out | ||
// Currently the feature is supported only on CPU and GPU, natively or by | ||
// software emulation. | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// RUNx: %ACC_RUN_PLACEHOLDER %t.out | ||
|
||
//==---------- bfloat16_conversions.cpp - SYCL bfloat16 type 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 | ||
// | ||
//===---------------------------------------------------------------------===// | ||
|
||
#include <iostream> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
|
||
template <typename T> T calculate(T a, T b) { | ||
sycl::ext::oneapi::bfloat16 x = -a; | ||
sycl::ext::oneapi::bfloat16 y = b; | ||
sycl::ext::oneapi::bfloat16 z = x + y; | ||
T result = z; | ||
return result; | ||
} | ||
|
||
template <typename T> int test_device(queue Q) { | ||
T data[3] = {-7.0f, 8.1f, 0.0f}; | ||
|
||
buffer<T, 1> buf{data, 3}; | ||
Q.submit([&](handler &cgh) { | ||
accessor numbers{buf, cgh, read_write}; | ||
cgh.single_task([=]() { numbers[2] = calculate(numbers[0], numbers[1]); }); | ||
}); | ||
|
||
host_accessor hostOutAcc{buf, read_only}; | ||
std::cout << "Device Result = " << hostOutAcc[2] << std::endl; | ||
if (hostOutAcc[2] == 15.125f) | ||
return 0; | ||
return 1; | ||
} | ||
|
||
template <typename T> int test_host() { | ||
T a{-5.6f}; | ||
T b{-1.1f}; | ||
T result = calculate(a, b); | ||
std::cout << "Host Result = " << result << std::endl; | ||
if (result == 4.5f) | ||
return 0; | ||
return 1; | ||
} | ||
|
||
int main() { | ||
queue Q; | ||
int result; | ||
result = test_host<sycl::half>(); | ||
result |= test_host<float>(); | ||
if (Q.get_device().has(aspect::fp16)) | ||
result |= test_device<sycl::half>(Q); | ||
result |= test_device<float>(Q); | ||
if (result) | ||
std::cout << "FAIL\n"; | ||
else | ||
std::cout << "PASS\n"; | ||
|
||
return result; | ||
} |
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,83 @@ | ||
/// | ||
/// Check if bfloat16 example works using fallback libraries | ||
/// | ||
|
||
// REQUIRES: opencl-aot, ocloc, cpu, gpu-intel-gen9 | ||
// UNSUPPORTED: cuda | ||
// CUDA is not compatible with SPIR. | ||
|
||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64 %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend "-device gen9" %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend "-device *" %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_gen -Xsycl-target-backend=spir64_gen "-device gen9" %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen "-device gen9" %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can add the following test cases:
These are interesting because they compile for PVC (native bfloat support) and run on CPU (fallback support). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_gen -Xsycl-target-backend=spir64_gen "-device pvc" %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen "-device pvc" %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using sycl::ext::oneapi::bfloat16; | ||
|
||
float foo(float a, float b) { | ||
// Convert from float to bfloat16. | ||
bfloat16 A{a}; | ||
bfloat16 B{b}; | ||
|
||
// Convert A and B from bfloat16 to float, do addition on floating-point | ||
// numbers, then convert the result to bfloat16 and store it in C. | ||
bfloat16 C = A + B; | ||
|
||
// Return the result converted from bfloat16 to float. | ||
return C; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
float data[3] = {7.0f, 8.1f, 0.0f}; | ||
|
||
float result_host = foo(7.0f, 8.1f); | ||
std::cout << "CPU Result = " << result_host << std::endl; | ||
if (std::abs(15.1f - result_host) > 0.1f) { | ||
std::cout << "Test failed. Expected CPU Result ~= 15.1" << std::endl; | ||
return 1; | ||
} | ||
|
||
queue deviceQueue; | ||
buffer<float, 1> buf{data, 3}; | ||
|
||
deviceQueue.submit([&](handler &cgh) { | ||
accessor numbers{buf, cgh, read_write}; | ||
cgh.single_task([=]() { numbers[2] = foo(numbers[0], numbers[1]); }); | ||
}); | ||
|
||
host_accessor hostOutAcc{buf, read_only}; | ||
float result_device = hostOutAcc[2]; | ||
std::cout << "GPU Result = " << result_device << std::endl; | ||
if (std::abs(result_host - result_device) > 0.1f) { | ||
std::cout << "Test failed. CPU Result !~= GPU result" << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Line 225, should it be ext_oneapi_bfloat16_math_functions?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be ext_oneapi_bfloat16_math_functions. Made the change.