Comments (3)
Do we have any idea what issues do we have with optimised IR? Would it be worth running a some tests and collect the issues we find?
One common issue we have with translation of optimized LLVM IR is type narrowing. Some passes will narrow types when they can prove the operation can be performed with a smaller type. This can cause conflicts as OpenCL SPIR-V only allows i8/16/32/64. Common occurrences with our tests is narrowing to i31 or i1 (bool treated as integer). From what I know, this is mainly due to insn combine and the switch statement narrowing pass.
Would support for this be easier to implement in a LLVM backend rather then translation format?
Dealing with optimized IR requires a type legalizer to run. LLVM has infrastructure to deals with this as it impacts all backends but I'm not sure if it can be reused outside the CodeGen infrastructure.
Is this a valuable use case?
To me offline optimization is a valuable use case, it is not because SPIR-V is the only input your driver can consume that you want to prevent all optimizations. Also drivers are usually time constrained but offline compilers are way less constrained.
It also allows users to work around driver bugs.
from spirv-llvm-translator.
Here's a very real example where it fails:
struct S {
char i8_3[3];
};
kernel void test(global struct S *p, float3 v)
{
int3 tmp;
frexp(v, &tmp);
tmp += 1;
p->i8_3[0] = tmp.x;
p->i8_3[1] = tmp.y;
p->i8_3[2] = tmp.z;
}
This example works fine with LLVM10 but with LLVM trunk (as of Aug 14, 2020), it generates this:
%11 = shufflevector <3 x i32> %10, <3 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
%12 = bitcast <4 x i32> %11 to i128
%13 = trunc i128 %12 to i96
%14 = bitcast i96 %13 to <12 x i8>
%15 = extractelement <12 x i8> %14, i32 0
This uses i128
, i96
, and <12 x i8>
, none of which are valid types in SPIR-V. I'm not sure what pass causes it.
from spirv-llvm-translator.
This uses
i128
,i96
, and<12 x i8>
, none of which are valid types in SPIR-V. I'm not sure what pass causes it.
@jekstrand, there is a solution for the integer scalars issue, which I described in #481. I am going to contribute it to LLVM trunk soon.
I also filed another issue for unsupported vector sizes (#645), but unfortunately I don't know a good solution for that problem other than disable "canonicalization" for SPIR target (https://github.com/intel/llvm/pull/2143/files). We probably should discuss the proper solution with LLVM developers.
from spirv-llvm-translator.
Related Issues (20)
- OpIAddCarry and OpISubBorrow aren't conformant with spec
- OpSource parsing does not account for optional parameters
- Evaluate using Profile-Guided Optimization (PGO) and LLVM BOLT
- OpenCL (CLC++2021) compilation to SPIR-V fails HOT 9
- Null constant inserted by `memset` handling not added to entry points interface HOT 2
- DWARFv5: static data members declarations are DW_TAG_variable HOT 3
- Multiple issues after running llvm-spirv test-suite with ASAN. HOT 1
- Alignment decoration is applied to Variable instead of its type HOT 1
- Different enum value of HostAccessINTEL HOT 1
- trunk Fails to build from source error: ‘CapabilityLongConstantCompositeINTEL’ was not declared in this scope HOT 2
- Option to perform systematic SPIR-V module validation ? HOT 2
- Compilation fails: error: ‘CapabilityLongConstantCompositeINTEL’ was not declared HOT 1
- windows github workflow in-tree-build isn't fetching correct SPIRV-Headers commit
- translation from cuda file to spv file HOT 1
- Missing translation for OpIAddCarry, OpISubCarry, OpSMulExtended, OpUMulExtended HOT 2
- Please create an llvm_release_180 branch HOT 1
- [DebugInfo] Support non-instrinsic debug-info
- Linking fails if SPIRV-Tools is installed separately and found as a cmake package HOT 6
- SPIRVError.cpp misses #include "LLVMSPIRVLib.h" HOT 2
- Unification of argument type failed HOT 3
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 spirv-llvm-translator.