JuliaGPU/CUDA.jl

Expose `prmt` PTX intrinsic

Open

#1,424 opened on 2022年3月3日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Julia (274 forks)batch import
enhancementgood first issue

Repository metrics

Stars
 (1,408 stars)
PR merge metrics
 (平均マージ 5d 5h) (30d で 16 merged PRs)

説明

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

コントリビューターガイド