Comments (2)
This one is quite complicated
TL;DR: https://godbolt.org/z/zj9zedzf8
Memory
is in the global address space, thus the cast to(struct S*)
should be(global Struct *)
- Because
Memory
is just used to be casted tolong
, we need to compile with-cl-kernel-arg-info
to help clspv figure outMemory
type. Note that clvk compiles by default with this option. - As you are doing pointer arithmetic, you definitively need to use physical addressing (compile with
-physical-storage-buffers -arch=spir64
). We have aLogicalPointerToIntPass
but it does not support this case. It should be able to be implemented, but that would require some work.
With all that, this example is compiled correctly.
from clspv.
Thank you for looking into this Mr. Jodin.
The interesting thing is, in CLC++ mode, Clspv infers address spaces when memcpy is not involved, as you can see below. Clspv just converts remaining generic address spaces to global in the LowerAddrSpaceCastPass for simple loads and stores. However, there seems to be some difficulty doing this for memcpy.
When looking at Clang's IR from CLC++ you will see it extensively emits the generic addrspace(4), even when No function calls or generics are used! Because the programmer has no control of these, Clspv handling the generic spaces with memcpy is probably essential for stability. Here are some additional observations at #1179
Here the (int*) inference is working. Also when using external Clang compilation with optimizations, S* inference works too, because it has been reduced to a single int i1.
struct S { int i1; };
kernel void Kernel(global void* Memory)
{
long a = (long) Memory;
* (int*) a = 0; // OK, address space inferred
// * (S*) a = {}; // Fails, address space not inferred. OK if externally optimized
// * (global S*) a = {}; // OK, address space explicit
}
https://godbolt.org/z/qj4WhbMG1
Isn't it nice to have the modern syntax! :-)
from clspv.
Related Issues (20)
- Clspv crashes on IR input accessing array of structs with different field sizes HOT 3
- [Hashcat] lib/BitcastUtils.cpp:434 - Assertion `Values.size() % 2 == 0' failed.
- [Hashcat] Unsupported LLVM intrinsic llvm.bswap.i32(i32) HOT 1
- [Hashcat] UNREACHABLE executed at lib/BitcastUtils.cpp:1217 HOT 1
- [Hashcat] Assertion in BitcastUtils.cpp - `i < NumUserOperands && "getOperand() out of range!"` HOT 1
- sampler using unnormalised coordinates and 3d images HOT 1
- Unsupported llvm intrinsic llvm.fshr.i32(i32, i32, i32) HOT 2
- UNREACHABLE executed at lib/BitcastUtils.cpp:1218 HOT 3
- UNREACHABLE executed at lib/BitcastUtils.cpp:1218 HOT 2
- Assertion `Ty && "Invalid GetElementPtrInst indices for type!"' failed HOT 6
- UNREACHABLE executed at lib/BitcastUtils.cpp:1272 HOT 5
- UNREACHABLE executed at lib/SPIRVProducerPass.cpp:2399 HOT 5
- UNREACHABLE executed at lib/LowerPrivatePointerPHIPass.cpp:207 HOT 1
- UNREACHABLE executed at lib/BitcastUtils.cpp:1237 HOT 5
- UNREACHABLE executed at lib/SPIRVProducerPass.cpp:2369 HOT 2
- UNREACHABLE executed at lib/SPIRVProducerPass.cpp:5028
- UNREACHABLE executed at lib/BitcastUtils.cpp:104 HOT 2
- incorrect execution for simple reduction sample HOT 5
- Segfaults when passing struct in global memory by value to a function. HOT 1
- Incorrectly warns about mixing code and declarations. HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clspv.