forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ESIMD] Infer address space of pointer that are passed through invoke…
…_simd to ESIMD API to generate better code on BE (intel#14528)
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
16 changes: 16 additions & 0 deletions
16
sycl/test-e2e/ESIMD/PerformanceTests/invoke_simd_smoke.cpp
This file contains 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,16 @@ | ||
//==------------- invoke_simd_smoke.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-dg2 && level_zero | ||
// UNSUPPORTED: windows | ||
|
||
// RUN: mkdir -p %t.dir && %{build} -fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr -o %t.dir/exec.out | ||
// RUN: env IGC_VCSaveStackCallLinkage=1 IGC_VCDirectCallsOnly=1 IGC_DumpToCustomDir=%t.dir IGC_ShaderDumpEnable=1 %{run} %t.dir/exec.out | ||
// RUN: python3 %S/instruction_count.py %t.dir 149 OCL_asmc2becd046944fa5f_simd16_entry_0001.asm | ||
// RUN: echo "Baseline from driver version 1.3.29735" | ||
|
||
#include "../../InvokeSimd/invoke_simd_smoke.cpp" |
86 changes: 86 additions & 0 deletions
86
sycl/test/invoke_simd/invoke_simd_address_space_inferral.cpp
This file contains 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,86 @@ | ||
// RUN: %clangxx -fsycl -fsycl-device-only -Xclang -fsycl-allow-func-ptr -S %s -o %t.ll | ||
// RUN: sycl-post-link -O2 -device-globals -properties -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -lower-esimd -S %t.ll -o %t.table | ||
// RUN: FileCheck %s -input-file=%t_0.ll | ||
|
||
// The test validates proper address space inferral for a pointer passed to | ||
// invoke_simd callee that is used for ESIMD API memory API | ||
|
||
#include <sycl/detail/core.hpp> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/ext/oneapi/experimental/invoke_simd.hpp> | ||
#include <sycl/ext/oneapi/experimental/uniform.hpp> | ||
#include <sycl/usm.hpp> | ||
|
||
#include <functional> | ||
#include <iostream> | ||
#include <type_traits> | ||
|
||
using namespace sycl::ext::oneapi::experimental; | ||
using namespace sycl; | ||
namespace esimd = sycl::ext::intel::esimd; | ||
|
||
constexpr int VL = 32; | ||
|
||
__attribute__((always_inline)) void ESIMD_CALLEE(float *A, float *B, | ||
int i) SYCL_ESIMD_FUNCTION { | ||
esimd::simd<float, VL> a; | ||
a.copy_from(A + i); | ||
a.copy_to(B + i); | ||
} | ||
|
||
[[intel::device_indirectly_callable]] SYCL_EXTERNAL void __regcall SIMD_CALLEE1( | ||
float *A, float *B, int i) SYCL_ESIMD_FUNCTION { | ||
ESIMD_CALLEE(A, B, i); | ||
} | ||
bool test() { | ||
constexpr unsigned Size = 1024; | ||
constexpr unsigned GroupSize = 4 * VL; | ||
|
||
queue q; | ||
|
||
auto dev = q.get_device(); | ||
float *A = malloc_shared<float>(Size, q); | ||
|
||
sycl::range<1> GlobalRange{Size}; | ||
// Number of workitems in each workgroup. | ||
sycl::range<1> LocalRange{GroupSize}; | ||
|
||
sycl::nd_range<1> Range(GlobalRange, LocalRange); | ||
|
||
try { | ||
auto e = q.submit([&](handler &cgh) { | ||
local_accessor<float, 1> LocalAcc(Size, cgh); | ||
cgh.parallel_for(Range, [=](nd_item<1> item) [[intel::reqd_sub_group_size( | ||
VL)]] { | ||
sycl::group<1> g = item.get_group(); | ||
sycl::sub_group sg = item.get_sub_group(); | ||
|
||
unsigned int i = g.get_group_id() * g.get_local_range() + | ||
sg.get_group_id() * sg.get_max_local_range(); | ||
|
||
invoke_simd( | ||
sg, SIMD_CALLEE1, uniform{A}, | ||
uniform{LocalAcc.template get_multi_ptr<access::decorated::yes>() | ||
.get()}, | ||
uniform{i}); | ||
}); | ||
}); | ||
e.wait(); | ||
} catch (sycl::exception const &e) { | ||
std::cout << "SYCL exception caught: " << e.what() << '\n'; | ||
sycl::free(A, q); | ||
return false; | ||
} | ||
|
||
sycl::free(A, q); | ||
|
||
return 0; | ||
// CHECK: addrspacecast ptr addrspace(4) %A to ptr addrspace(1) | ||
// CHECK: addrspacecast ptr addrspace(4) %B to ptr addrspace(3) | ||
} | ||
|
||
int main() { | ||
test(); | ||
|
||
return 0; | ||
} |