JuliaGPU/CUDA.jl

Expose `prmt` PTX intrinsic

Open

#1424 aperta il 3 mar 2022

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Julia (274 fork)batch import
enhancementgood first issue

Metriche repository

Star
 (1408 star)
Metriche merge PR
 (Merge medio 5g 5h) (16 PR mergiate in 30 g)

Descrizione

Is your feature request related to a problem? Please describe.

CUDA.jl offers __byte_perm, which is very similar to the prmt PTX intrinsic, but lacks one important feature: One cannot use it for sign extension. From the prmt documentation:

"The msb defines if the byte value should be copied, or if the sign (msb of the byte) should be replicated over all 8 bits of the target position (sign extend of the byte value); msb=0 means copy the literal value; msb=1 means replicate the sign."

This feature is missing from the __byte_perm intrinsic.

Describe the solution you'd like

I would like CUDA.jl to offer access to the prmt PTX intrinsic, presumably under a different name (maybe prmt).

Describe alternatives you've considered

I am currently manually defining this function:

function cuda_prmt(x::UInt32, y::UInt32, op::UInt32)
    LLVM.Interop.@asmcall("prmt.b32 \$0, \$1, \$2, \$3;", "=r,r,r,i", UInt32, Tuple{UInt32,UInt32,UInt32}, x, y, op)
end

Additional context

Guida contributor