-
Couldn't load subscription status.
- Fork 793
Closed
Copy link
Labels
Description
At SYCL level:
#include <sycl/sycl.hpp>
using namespace sycl;
using namespace ext::oneapi::experimental;
using namespace ext::intel::experimental;
using store_hint = annotated_ptr<
float,
decltype(properties(
write_hint<cache_control<cache_mode::write_through, cache_level::L1>,
cache_control<cache_mode::write_back, cache_level::L2,
cache_level::L3>,
cache_control<cache_mode::streaming, cache_level::L4>>))>;
SYCL_EXTERNAL void foo(float *p) { *(store_hint{p/*+1*/}) = 42.0f; }
Or, at LLVM IR level:
; RUN: opt -passes=compile-time-properties %s -disable-output
; Make sure annotation on non-Instruction (e.g. function argument) doesn't crash.
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1"
target triple = "spir64-unknown-unknown"
@.str = private unnamed_addr addrspace(1) constant [16 x i8] c"sycl-properties\00", section "llvm.metadata"
@.str.1 = private unnamed_addr addrspace(1) constant [11 x i8] c"/some/path\00", section "llvm.metadata"
@.str.2 = private unnamed_addr addrspace(1) constant [22 x i8] c"sycl-cache-write-hint\00", section "llvm.metadata"
@.str.3 = private unnamed_addr addrspace(1) constant [10 x i8] c"101713920\00", section "llvm.metadata"
@.args = private unnamed_addr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) @.str.2, ptr addrspace(1) @.str.3 }, section "llvm.metadata"
define dso_local spir_func void @_Z3fooPf(ptr addrspace(4) noundef %p) local_unnamed_addr {
entry:
; %add.ptr = getelementptr inbounds nuw i8, ptr addrspace(4) %p, i64 4
; %0 = tail call ptr addrspace(4) @llvm.ptr.annotation.p4.p1(ptr addrspace(4) %add.ptr, ptr addrspace(1) @.str, ptr addrspace(1) @.str.1, i32 77, ptr addrspace(1) @.args)
%0 = tail call ptr addrspace(4) @llvm.ptr.annotation.p4.p1(ptr addrspace(4) %p, ptr addrspace(1) @.str, ptr addrspace(1) @.str.1, i32 77, ptr addrspace(1) @.args)
store float 4.200000e+01, ptr addrspace(4) %0, align 4
ret void
}
declare ptr addrspace(4) @llvm.ptr.annotation.p4.p1(ptr addrspace(4), ptr addrspace(1), ptr addrspace(1), i32, ptr addrspace(1))
$ opt --passes=compile-time-properties cache_control_argument_ptr.ll -disable-output
/iusers/aeloviko/sycl/build.debug/bin/opt: WARNING: failed to create target machine for 'spir64-unknown-unknown': unable to get target for 'spir64-unknown-unknown', see --version and --triple.
opt: .../llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::Instruction, From = llvm::Value]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
...
#12 0x000055b050fd4328 decltype(auto) llvm::cast<llvm::Instruction, llvm::Value>(llvm::Value*) .../llvm/include/llvm/Support/Casting.h:579:10
#13 0x000055b0529c0bbd llvm::CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(llvm::Module&, llvm::IntrinsicInst*, llvm::SmallVectorImpl<llvm::IntrinsicInst*>&) .../llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp:953:12
...
Corresponding source code:
llvm/llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp
Lines 947 to 958 in 7c62a99
| if (CacheProp) { | |
| LLVMContext &Ctx = M.getContext(); | |
| unsigned MDKindID = Ctx.getMDKindID(SPIRV_DECOR_MD_KIND); | |
| if (!FPGAProp) { | |
| // If there are no annotations other than cache controls we can apply the | |
| // controls to the pointer and remove the intrinsic. | |
| auto PtrInstr = cast<Instruction>(IntrInst->getArgOperand(0)); | |
| PtrInstr->setMetadata(MDKindID, MDTuple::get(Ctx, MDOpsCacheProp)); | |
| // Replace all uses of IntrInst with first operand | |
| IntrInst->replaceAllUsesWith(PtrInstr); | |
| // Delete the original IntrInst | |
| RemovableAnnotations.push_back(IntrInst); |