Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6197b60
Duplicating ESIMD samples for esimd_emulator
dongkyunahn-intel Dec 13, 2021
c5b6567
Adding 'esimd_emualtor' as supported SYCL backend
dongkyunahn-intel Jan 18, 2022
68c4c1f
Revert "Adding 'esimd_emualtor' as supported SYCL backend"
dongkyunahn-intel Jan 19, 2022
08c0158
Reverting changes in 'SYCL/ESIMD/sycl_esimd_mix.cpp'
dongkyunahn-intel Jan 19, 2022
1febb1b
Fixing typo in comment for SYCL/ESIMD/vadd_1d.cpp
dongkyunahn-intel Jan 19, 2022
647368d
Apply suggestions from code review
dongkyunahn-intel Jan 25, 2022
bbc31d9
Marking ESIMD kernels 'UNSUPPORTED' for esimd_emulator backend
dongkyunahn-intel Jan 25, 2022
18df6bb
clang-format error fix
dongkyunahn-intel Jan 25, 2022
d61e3be
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
dongkyunahn-intel Jan 25, 2022
b5bb143
XFAIL markups replacing UNSUPPORTED
dongkyunahn-intel Jan 25, 2022
c213138
clang-format fix
dongkyunahn-intel Jan 27, 2022
092f7c1
'esimd_emulator' as deprecated name for 'ext_intel_esimd_emulator'
dongkyunahn-intel Jan 27, 2022
cb09441
Missing TODO comments for esimd_emulator support markup
dongkyunahn-intel Jan 27, 2022
c53aa85
Adding dummy codes to invoke piProgramBuild for vc_codegen
dongkyunahn-intel Jan 27, 2022
697e3bd
Removing HOST_RUN_PLACEHOLDER for ESIMD Kernels
dongkyunahn-intel Jan 28, 2022
bbdb607
Recovering 'esimd_check_vc_codegen.cpp' to its initial import version
dongkyunahn-intel Jan 28, 2022
a4c51cc
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
dongkyunahn-intel Jan 31, 2022
e70bab1
Merge branch 'intel' of https://github.com/intel/llvm-test-suite into…
dongkyunahn-intel Feb 4, 2022
a97e08f
Changing 'UNSUPPORTED' to 'XFAIL' for esimd_emulator backend
dongkyunahn-intel Feb 4, 2022
b6601cf
Marking 'XFAIL' for newly added tests
dongkyunahn-intel Feb 5, 2022
6580013
Revert "Removing HOST_RUN_PLACEHOLDER for ESIMD Kernels"
dongkyunahn-intel Feb 5, 2022
4c955cf
Revert "'esimd_emulator' as deprecated name for 'ext_intel_esimd_emul…
dongkyunahn-intel Feb 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions SYCL/ESIMD/esimd_check_vc_codegen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//==-------- esimd_check_vc_codegen.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
// UNSUPPORTED: cuda || hip
// esimd_emulator does not support online-compiler that invokes 'piProgramBuild'
// UNSUPPORTED: esimd_emulator
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER

#include "esimd_test_utils.hpp"

#include <CL/sycl.hpp>
#include <iostream>
#include <sycl/ext/intel/experimental/esimd.hpp>

using namespace cl::sycl;

int main(void) {
constexpr unsigned Size = 1024 * 128;
constexpr unsigned VL = 16;

float *A = new float[Size];
float *B = new float[Size];
float *C = new float[Size];

for (unsigned i = 0; i < Size; ++i) {
A[i] = B[i] = i;
C[i] = 0.0f;
}

try {
buffer<float, 1> bufa(A, range<1>(Size));
buffer<float, 1> bufb(B, range<1>(Size));
buffer<float, 1> bufc(C, range<1>(Size));

// We need that many workgroups
range<1> GlobalRange{Size / VL};

// We need that many threads in each group
range<1> LocalRange{1};

queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());

auto dev = q.get_device();
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";

auto e = q.submit([&](handler &cgh) {
auto PA = bufa.get_access<access::mode::read>(cgh);
auto PB = bufb.get_access<access::mode::read>(cgh);
auto PC = bufc.get_access<access::mode::write>(cgh);
cgh.parallel_for<class Test>(
GlobalRange * LocalRange, [=](id<1> i) SYCL_ESIMD_KERNEL {
using namespace sycl::ext::intel::experimental::esimd;
unsigned int offset = i * VL * sizeof(float);
simd<float, VL> va;
va.copy_from(PA, offset);
simd<float, VL> vb;
vb.copy_from(PB, offset);
simd<float, VL> vc = va + vb;
vc.copy_to(PC, offset);
});
});
e.wait();
} catch (sycl::exception const &e) {
std::cout << "SYCL exception caught: " << e.what() << '\n';

delete[] A;
delete[] B;
delete[] C;
return 1;
}

int err_cnt = 0;

for (unsigned i = 0; i < Size; ++i) {
if (A[i] + B[i] != C[i]) {
if (++err_cnt < 10) {
std::cout << "failed at index " << i << ", " << C[i] << " != " << A[i]
<< " + " << B[i] << "\n";
}
}
}
if (err_cnt > 0) {
std::cout << " pass rate: "
<< ((float)(Size - err_cnt) / (float)Size) * 100.0f << "% ("
<< (Size - err_cnt) << "/" << Size << ")\n";
}

delete[] A;
delete[] B;
delete[] C;

std::cout << (err_cnt > 0 ? "FAILED\n" : "Passed\n");
return err_cnt > 0 ? 1 : 0;
Comment on lines +77 to +99

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int err_cnt = 0;
for (unsigned i = 0; i < Size; ++i) {
if (A[i] + B[i] != C[i]) {
if (++err_cnt < 10) {
std::cout << "failed at index " << i << ", " << C[i] << " != " << A[i]
<< " + " << B[i] << "\n";
}
}
}
if (err_cnt > 0) {
std::cout << " pass rate: "
<< ((float)(Size - err_cnt) / (float)Size) * 100.0f << "% ("
<< (Size - err_cnt) << "/" << Size << ")\n";
}
delete[] A;
delete[] B;
delete[] C;
std::cout << (err_cnt > 0 ? "FAILED\n" : "Passed\n");
return err_cnt > 0 ? 1 : 0;
return 0;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbobrovs , esimd_check_vc_codegen.cpp fails after being simplified with single_task - for both open_cl and level_zero. Maybe it has to be reverted.

[2022-01-27T05:52:29.296Z] /netbatch/donb02499_00/runDir/jenkins-dir/workspace/LLVM-Test-Suite-CI-TMP/LLVM-Test-Suite-CI-Linux/llvm-test-suite/SYCL/ESIMD/esimd_check_vc_codegen.cpp:41:11: error: CHECK: expected string not found in input
[2022-01-27T05:52:29.296Z] // CHECK: <const char *>: {{.*}}-vc-codegen
[2022-01-27T05:52:29.296Z]           ^
[2022-01-27T05:52:29.296Z] <stdin>:415:2: note: scanning from here
[2022-01-27T05:52:29.296Z]  <unknown> : 0x7056b0
[2022-01-27T05:52:29.296Z]  ^
[2022-01-27T05:52:29.296Z] <stdin>:418:2: note: possible intended match here
[2022-01-27T05:52:29.296Z]  <const char *>: 
[2022-01-27T05:52:29.296Z]  ^
[2022-01-27T05:52:29.296Z] 

}

// CHECK: ---> piProgramBuild(
// CHECK: <const char *>: {{.*}}-vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
29 changes: 6 additions & 23 deletions SYCL/ESIMD/sycl_esimd_mix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

// REQUIRES: gpu
// UNSUPPORTED: cuda || hip
// TODO/FIXME: esimd_emulator support - timeout
// XFAIL: esimd_emulator
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER --check-prefixes=CHECK,CHECK-NO-VAR
// RUN: env SYCL_PROGRAM_COMPILE_OPTIONS="-g" SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER --check-prefixes=CHECK,CHECK-WITH-VAR
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: env SYCL_PROGRAM_COMPILE_OPTIONS="-g" %GPU_RUN_PLACEHOLDER %t.out

#include "esimd_test_utils.hpp"

Expand Down Expand Up @@ -123,24 +125,5 @@ int main(void) {
return 0;
}

// Regular SYCL kernel is compiled without -vc-codegen option

// CHECK-LABEL: ---> piProgramBuild(
// CHECK-NOT: -vc-codegen
// CHECK-WITH-VAR: -g
// CHECK-NOT: -vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
// CHECK-LABEL: ---> piKernelCreate(
// CHECK: <const char *>: {{.*}}SyclKernel
// CHECK: ) ---> pi_result : PI_SUCCESS

// For ESIMD kernels, -vc-codegen option is always preserved,
// regardless of SYCL_PROGRAM_COMPILE_OPTIONS value.

// CHECK-LABEL: ---> piProgramBuild(
// CHECK-NO-VAR: -vc-codegen
// CHECK-WITH-VAR: -g -vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
// CHECK-LABEL: ---> piKernelCreate(
// CHECK: <const char *>: {{.*}}EsimdKernel
// CHECK: ) ---> pi_result : PI_SUCCESS
// 'CHECK' commands for checking 'vc-codegen' are moved to
// 'sycl_esimd_mix_check_build_opts.cpp'
148 changes: 148 additions & 0 deletions SYCL/ESIMD/sycl_esimd_mix_check_build_opts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//==--- sycl_esimd_mix_check_build_opts.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
//
//===----------------------------------------------------------------------===//
// This is basic test for mixing SYCL and ESIMD kernels in the same source and
// in the same program .

// REQUIRES: gpu
// UNSUPPORTED: cuda || hip
// esimd_emulator does not support online-compiler that invokes 'piProgramBuild'
// UNSUPPORTED: esimd_emulator
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER --check-prefixes=CHECK,CHECK-NO-VAR
// RUN: env SYCL_PROGRAM_COMPILE_OPTIONS="-g" SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER --check-prefixes=CHECK,CHECK-WITH-VAR

#include "esimd_test_utils.hpp"

#include <CL/sycl.hpp>
#include <iostream>
#include <sycl/ext/intel/experimental/esimd.hpp>

using namespace cl::sycl;

bool checkResult(const std::vector<float> &A, int Inc) {
int err_cnt = 0;
unsigned Size = A.size();

for (unsigned i = 0; i < Size; ++i) {
if (A[i] != i + Inc)
if (++err_cnt < 10)
std::cerr << "failed at A[" << i << "]: " << A[i] << " != " << i + Inc
<< "\n";
}

if (err_cnt > 0) {
std::cout << " pass rate: "
<< ((float)(Size - err_cnt) / (float)Size) * 100.0f << "% ("
<< (Size - err_cnt) << "/" << Size << ")\n";
return false;
}
return true;
}

int main(void) {
constexpr unsigned Size = 32;
constexpr unsigned VL = 16;

std::vector<float> A(Size);

for (unsigned i = 0; i < Size; ++i) {
A[i] = i;
}

try {
buffer<float, 1> bufa(A.data(), range<1>(Size));

// We need that many workgroups
cl::sycl::range<1> GlobalRange{Size};
// We need that many threads in each group
cl::sycl::range<1> LocalRange{1};

queue q(gpu_selector{}, esimd_test::createExceptionHandler());

auto dev = q.get_device();
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";

auto e = q.submit([&](handler &cgh) {
auto PA = bufa.get_access<access::mode::read_write>(cgh);
cgh.parallel_for<class SyclKernel>(GlobalRange * LocalRange,
[=](id<1> i) { PA[i] = PA[i] + 1; });
});
e.wait();
} catch (cl::sycl::exception const &e) {
std::cout << "SYCL exception caught: " << e.what() << '\n';
return 2;
}

if (checkResult(A, 1)) {
std::cout << "SYCL kernel passed\n";
} else {
std::cout << "SYCL kernel failed\n";
return 1;
}

try {
buffer<float, 1> bufa(A.data(), range<1>(Size));

// We need that many workgroups
cl::sycl::range<1> GlobalRange{Size / VL};
// We need that many threads in each group
cl::sycl::range<1> LocalRange{1};

queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());

auto dev = q.get_device();
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";

auto e = q.submit([&](handler &cgh) {
auto PA = bufa.get_access<access::mode::read_write>(cgh);
cgh.parallel_for<class EsimdKernel>(
GlobalRange * LocalRange, [=](id<1> i) SYCL_ESIMD_KERNEL {
using namespace sycl::ext::intel::experimental::esimd;
unsigned int offset = i * VL * sizeof(float);
simd<float, VL> va;
va.copy_from(PA, offset);
simd<float, VL> vc = va + 1;
vc.copy_to(PA, offset);
});
});
e.wait();
} catch (cl::sycl::exception const &e) {
std::cout << "SYCL exception caught: " << e.what() << '\n';
return 2;
}

if (checkResult(A, 2)) {
std::cout << "ESIMD kernel passed\n";
} else {
std::cout << "ESIMD kernel failed\n";
return 1;
}
return 0;
}

// Regular SYCL kernel is compiled without -vc-codegen option

// CHECK-LABEL: ---> piProgramBuild(
// CHECK-NOT: -vc-codegen
// CHECK-WITH-VAR: -g
// CHECK-NOT: -vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
// CHECK-LABEL: ---> piKernelCreate(
// CHECK: <const char *>: {{.*}}SyclKernel
// CHECK: ) ---> pi_result : PI_SUCCESS

// For ESIMD kernels, -vc-codegen option is always preserved,
// regardless of SYCL_PROGRAM_COMPILE_OPTIONS value.

// CHECK-LABEL: ---> piProgramBuild(
// CHECK-NO-VAR: -vc-codegen
// CHECK-WITH-VAR: -g -vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
// CHECK-LABEL: ---> piKernelCreate(
// CHECK: <const char *>: {{.*}}EsimdKernel
// CHECK: ) ---> pi_result : PI_SUCCESS
9 changes: 5 additions & 4 deletions SYCL/ESIMD/vadd_1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
//===----------------------------------------------------------------------===//
// REQUIRES: gpu
// UNSUPPORTED: cuda || hip
// TODO: esimd_emulator support - enable __esimd_oword_ld_unaligned
// XFAIL: esimd_emulator
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_PI_TRACE=-1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
// RUN: %GPU_RUN_PLACEHOLDER %t.out

#include "esimd_test_utils.hpp"

Expand Down Expand Up @@ -97,6 +99,5 @@ int main(void) {
return err_cnt > 0 ? 1 : 0;
}

// CHECK: ---> piProgramBuild(
// CHECK: <const char *>: {{.*}}-vc-codegen
// CHECK: ) ---> pi_result : PI_SUCCESS
// 'CHECK' commands for checking 'vc-codegen' are moved to
// 'sycl_esimd_mix_check_build_opts.cpp'
3 changes: 2 additions & 1 deletion SYCL/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
'opencl',
'cuda',
'hip',
'level_zero']
'level_zero',
'esimd_emulator']

if config.sycl_be not in supported_sycl_be:
lit_config.error("Unknown SYCL BE specified '" +
Expand Down