[LLVMdev] [cfe-dev] SPIR provisional specification is now available in the Khronos website
james at jamesmolloy.co.uk
Thu Sep 27 06:42:26 PDT 2012
Indeed; I agree it is not an implementation detail as potentially valid
SPIR could be almost untranslatable to valid code running on a target
without dedicated workgroup-local memory.
Micah: the problem can be distilled down to: __local variables in SPIR are
represented as Constants (GlobalVariable : public Constant), but they are
not in fact constant, for a device with no workgroup-local memory.
So it is valid SPIR, as the specification stands, to manipulate __local
variables as Constants in a way that is extremely difficult to undo. That
is, in order to transform SPIR to code that can run on a CPU, the
GlobalVariable (which is a subclass of Constant) must be replaced with a
dynamically calculated Value (which is not a subclass of constant).
The GlobalVariable can be used in ConstantExprs (of which there are many
valid), and converting ConstantExprs to their Instruction corrollaries is
very difficult in the general case.
On 27 September 2012 08:41, Pekka Jääskeläinen <pekka.jaaskelainen at tut.fi>wrote:
> On 09/26/2012 08:21 PM, Villmow, Micah wrote:
>> It is my view that this is an implementation detail and not an issue
>> with the SPIR spec. As SPIR is just a representation of a program in a
>> portable manner, it is up to the consumer of SPIR to correctly set up
>> the kernels based on the devices calling convention/ABI when the SPIR
>> binary is loaded for that specific device.
> The question was not about implementing the automatic locals (which is
> a device specific detail, like you correctly state), but enforcing LLVM IR
> for the automatic locals that potentially leads to illegal optimizations
> due to the inadequate semantics of global variables for this use.
> If SPIR enforces this type of bitcode for the automatic locals, it means
> such optimizations do happen (the optimizations might be beneficial in
> general so they cannot be just disabled due to the SPIR flaw), the
> implementers have to work around them with kludges to implement the real
> automatic local semantics. What's worse, at some point there might be
> an optimization that is not easily worked around which makes this part of
> SPIR specs look bad.
> Of course it's possible the constantGEP case was the only problem we will
> ever get from this issue, but I wouldn't rely on it in an IR standard
> specification if it's possible to avoid it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev