JuliaGPU/CUDA.jl

Expose `prmt` PTX intrinsic

Open

#1 424 ouverte le 3 mars 2022

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)Julia (274 forks)batch import
enhancementgood first issue

Métriques du dépôt

Stars
 (1 408 stars)
Métriques de merge PR
 (Merge moyen 5j 5h) (16 PRs mergées en 30 j)

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

Guide contributeur