JuliaGPU/CUDA.jl

Expose `prmt` PTX intrinsic

Open

#1.424 aberto em 3 de mar. de 2022

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Julia (274 forks)batch import
enhancementgood first issue

Métricas do repositório

Stars
 (1.408 stars)
Métricas de merge de PR
 (Mesclagem média 5d 5h) (16 fundiu PRs em 30d)

Description

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

Guia do colaborador