Movatterモバイル変換


[0]ホーム

URL:


GitHub

SIMD Support

TypeVecElement{T} is intended for building libraries of SIMD operations. Practical use of it requires usingllvmcall. The type is defined as:

struct VecElement{T}    value::Tend

It has a special compilation rule: a homogeneous tuple ofVecElement{T} maps to an LLVMvector type whenT is a primitive bits type.

At-O3, the compilermight automatically vectorize operations on such tuples. For example, the following program, when compiled withjulia -O3 generates two SIMD addition instructions (addps) on x86 systems:

const m128 = NTuple{4,VecElement{Float32}}function add(a::m128, b::m128)    (VecElement(a[1].value+b[1].value),     VecElement(a[2].value+b[2].value),     VecElement(a[3].value+b[3].value),     VecElement(a[4].value+b[4].value))endtriple(c::m128) = add(add(c,c),c)code_native(triple,(m128,))

However, since the automatic vectorization cannot be relied upon, future use will mostly be via libraries that usellvmcall.

Settings


This document was generated withDocumenter.jl version 1.8.0 onWednesday 9 July 2025. Using Julia version 1.11.6.


[8]ページ先頭

©2009-2025 Movatter.jp