JuliaGPU/CUDA.jl

Expose `prmt` PTX intrinsic

Open

#1.424 geöffnet am 3. März 2022

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Julia (274 Forks)batch import
enhancementgood first issue

Repository-Metriken

Stars
 (1.408 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 5h) (16 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide