Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CPU loops simd & ivdep #436

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/KernelAbstractions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,27 @@ end
function construct(backend::Backend, ::S, ::NDRange, xpu_name::XPUName) where {Backend<:Union{CPU,GPU}, S<:_Size, NDRange<:_Size, XPUName}
return Kernel{Backend, S, NDRange, XPUName}(backend, xpu_name)
end

"""
argconvert(::Kernel, arg)

Convert arguments to the device side representation.
"""
argconvert(k::Kernel{T}, arg) where T =
error("Don't know how to convert arguments for Kernel{$T}")

# Enzyme support
supports_enzyme(::Backend) = false
function __fake_compiler_job end

###
# Extras
# - LoopInfo
###

include("extras/extras.jl")

include("reflection.jl")

###
# Compiler
Expand Down Expand Up @@ -714,27 +735,6 @@ end
__size(args::Tuple) = Tuple{args...}
__size(i::Int) = Tuple{i}

"""
argconvert(::Kernel, arg)

Convert arguments to the device side representation.
"""
argconvert(k::Kernel{T}, arg) where T =
error("Don't know how to convert arguments for Kernel{$T}")

# Enzyme support
supports_enzyme(::Backend) = false
function __fake_compiler_job end

###
# Extras
# - LoopInfo
###

include("extras/extras.jl")

include("reflection.jl")

# Initialized

@kernel function init_kernel(arr, f::F, ::Type{T}) where {F, T}
Expand Down
2 changes: 2 additions & 0 deletions src/extras/loopinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module MD
unroll_disable() = (Symbol("llvm.loop.unroll.disable"), 1)
unroll_enable() = (Symbol("llvm.loop.unroll.enable"), 1)
unroll_full() = (Symbol("llvm.loop.unroll.full"), 1)
simd() = Symbol("julia.simdloop")
ivdep() = Symbol("julia.ivdep")
end

function loopinfo(expr, nodes...)
Expand Down
3 changes: 3 additions & 0 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ function split(stmts,
return new_stmts
end

import .Extras: LoopInfo

function emit(loop)
idx = gensym(:I)
for stmt in loop.indicies
Expand Down Expand Up @@ -285,6 +287,7 @@ function emit(loop)
$__validindex(__ctx__, $idx) || continue
$(loop.indicies...)
$(unblock(body))
$(Expr(:loopinfo, LoopInfo.MD.simd(), LoopInfo.MD.ivdep()))
end
end
push!(stmts, loopexpr)
Expand Down
Loading