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
[ESIMD] Add a LIT test verifying DPAS with 2 tfloat32 arguments #1180
Merged
v-klochkov
merged 3 commits into
intel:intel
from
v-klochkov:esimd_dpas_tf32_nosrc0_test
Aug 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,87 @@ | ||
| //==---------------- dpas_tf32.cpp - DPC++ ESIMD on-device 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-intel-pvc || esimd_emulator | ||
| // UNSUPPORTED: cuda || hip | ||
| // RUN: %clangxx -fsycl -DESIMD_XE_HPC %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // XFAIL: esimd_emulator | ||
|
|
||
| // The test verifies the low-level API for DPAS with 'tfloat32' types. | ||
| // It checks the versions of DPAS with and without the accumulator operand. | ||
|
|
||
| #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; | ||
|
|
||
| int main() { | ||
| queue Q; | ||
|
|
||
| constexpr int REPEAT_COUNT = 8; | ||
| constexpr int SYSTOLIC_DEPTH = 8; | ||
| constexpr int EXECUTION_SIZE = 16; | ||
|
|
||
| constexpr int M = REPEAT_COUNT; | ||
| constexpr int N = EXECUTION_SIZE; | ||
| constexpr int K = SYSTOLIC_DEPTH; // SYSTOLIC_DEPTH * OPS_PER_CHANNEL | ||
| float *A = malloc_shared<float>(M * K, Q); | ||
| float *B = malloc_shared<float>(K * N, Q); | ||
| float *C = malloc_shared<float>(M * N, Q); | ||
| float *D = malloc_shared<float>(M * N, Q); | ||
| for (int I = 0; I < M * K; ++I) | ||
| A[I] = I; | ||
| for (int I = 0; I < K * N; ++I) | ||
| B[I] = I; | ||
|
|
||
| Q.single_task([=]() SYCL_ESIMD_KERNEL { | ||
| simd<float, M * K> AVec(A); | ||
| simd<float, K * N> BVec(B); | ||
| auto AView = AVec.template bit_cast_view<uint>(); | ||
| auto BView = BVec.template bit_cast_view<uint>(); | ||
| // C(MxN) = A(MxK) * B(KxN) | ||
| simd<float, M *N> CVec = | ||
| dpas<argument_type::TF32, argument_type::TF32, SYSTOLIC_DEPTH, | ||
| REPEAT_COUNT, float, uint, uint, M * N, K * N, M * K>( | ||
| BView.read(), AView.read()); | ||
| CVec.copy_to(C); | ||
|
|
||
| // D(MxN) = D(MxN) + A(MxK) * B(KxN); | ||
| simd<float, M *N> DVec = 1.0; | ||
| DVec = dpas<argument_type::TF32, argument_type::TF32, SYSTOLIC_DEPTH, | ||
| REPEAT_COUNT, float, uint, uint, M * N, K * N, M * K>( | ||
| DVec, BView.read(), AView.read()); | ||
| DVec.copy_to(D); | ||
| }).wait(); | ||
|
|
||
| unsigned ErrCnt = 0; | ||
| for (unsigned I = 0; I < M * N && ErrCnt < 10; ++I) { | ||
|
||
| int m = I / N; | ||
| int n = I % N; | ||
| float RefResC = 0.0f; | ||
| for (int k = 0; k < K; ++k) | ||
| RefResC += float((m * K + k) * (k * N + n)); | ||
| if (std::abs(RefResC - C[I]) > 0.001) { | ||
| std::cerr << "C[i] vs ref: " << C[I] << " : " << RefResC << std::endl; | ||
| ErrCnt++; | ||
| } | ||
| float RefResD = RefResC + 1.0; | ||
| if (std::abs(RefResD - D[I]) > 0.001) { | ||
| std::cerr << "D[i] vs ref: " << D[I] << " : " << RefResD << std::endl; | ||
| ErrCnt++; | ||
| } | ||
| } | ||
| free(A, Q); | ||
| free(B, Q); | ||
| free(C, Q); | ||
| free(D, Q); | ||
|
|
||
| std::cout << (ErrCnt > 0 ? "FAILED\n" : "Passed\n"); | ||
| return ErrCnt > 0 ? 1 : 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.
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.
why not use custom selector and exception handler as in ESIMD tests?
queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());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.
because the way how CI works, the GPU selector will be chosen anyway.
Regarding exception handler..., Ok, I'll add it.
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.
Fixed in 21db007