Skip to content
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
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
KernelInterface = "4ee993da-d684-4d17-a7dd-4e58e78d92bf"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down Expand Up @@ -42,6 +43,7 @@ GPUArrays = "11.2.1"
GPUCompiler = "2 - 2.2.1"
GPUToolbox = "0.1, 0.2, 0.3, 1, 3"
KernelAbstractions = "0.9.39"
KernelInterface = "0.1"
LLVM = "6, 7, 8, 9"
NEO_jll = "=26.18.38308"
PrecompileTools = "1"
Expand Down
19 changes: 16 additions & 3 deletions src/compiler/compilation.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## gpucompiler interface implementation

struct oneAPICompilerParams <: AbstractCompilerParams end
Base.@kwdef struct oneAPICompilerParams <: AbstractCompilerParams
sub_group_size::Union{Nothing,Int} = nothing
end

const oneAPICompilerConfig = CompilerConfig{SPIRVCompilerTarget, oneAPICompilerParams}
const oneAPICompilerJob = CompilerJob{SPIRVCompilerTarget,oneAPICompilerParams}

Expand Down Expand Up @@ -48,6 +51,11 @@ function GPUCompiler.finish_module!(job::oneAPICompilerJob, mod::LLVM.Module,
Tuple{CompilerJob{SPIRVCompilerTarget}, typeof(mod), typeof(entry)},
job, mod, entry)

# Set the subgroup size
if job.config.params.sub_group_size !== nothing
metadata(entry)["intel_reqd_sub_group_size"] = MDNode([ConstantInt(Int32(job.config.params.sub_group_size))])
end

# OpenCL 2.0
push!(metadata(mod)["opencl.ocl.version"],
MDNode([ConstantInt(Int32(2)),
Expand Down Expand Up @@ -323,11 +331,16 @@ function _driver_supports_bfloat16_spirv(dev=device())
end
end

@noinline function _compiler_config(dev; kernel=true, name=nothing, always_inline=false, kwargs...)
@noinline function _compiler_config(dev; kernel=true, name=nothing, always_inline=false, sub_group_size=32, kwargs...)
properties = oneL0.module_properties(dev)
supports_fp16 = properties.fp16flags & oneL0.ZE_DEVICE_MODULE_FLAG_FP16 == oneL0.ZE_DEVICE_MODULE_FLAG_FP16
supports_fp64 = properties.fp64flags & oneL0.ZE_DEVICE_MODULE_FLAG_FP64 == oneL0.ZE_DEVICE_MODULE_FLAG_FP64

if sub_group_size ∉ oneL0.compute_properties(dev).subGroupSizes
@error("$sub_group_size is not a valid sub-group size for this device.")
end


# SPIR-V codegen path. The Aurora LTS NEO/IGC runtime only accepts SPIR-V from the
# Khronos translator; the rolling stack uses the LLVM SPIR-V back-end. GPUCompiler picks
# the tool from the target's `backend` field and loads the JLL lazily, so both can be
Expand Down Expand Up @@ -360,7 +373,7 @@ end

# create GPUCompiler objects
target = SPIRVCompilerTarget(; backend, extensions = extensions_str, supports_fp16, supports_fp64, supports_bfloat16, kwargs...)
params = oneAPICompilerParams()
params = oneAPICompilerParams(; sub_group_size)
CompilerConfig(target, params; kernel, name, always_inline)
end

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export @oneapi, zefunction, kernel_convert
## high-level @oneapi interface

const MACRO_KWARGS = [:launch]
const COMPILER_KWARGS = [:kernel, :name, :always_inline]
const COMPILER_KWARGS = [:kernel, :name, :always_inline, :sub_group_size]
const LAUNCH_KWARGS = [:groups, :items, :queue]

"""
Expand Down
11 changes: 9 additions & 2 deletions src/oneAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using SpecialFunctions
import Preferences

import KernelAbstractions: KernelAbstractions
import KernelInterface

using LLVM
using LLVM.Interop
Expand Down Expand Up @@ -76,12 +77,18 @@ include("gpuarrays.jl")
include("random.jl")
include("utils.jl")

include("oneAPIKernels.jl")
# KernelAbstractions
include("oneAPIKernelsOld.jl")
import .oneAPIKernels: oneAPIBackend
export oneAPIBackend

# KernelInterface
include("oneAPIKernels.jl")
import .oneAPIInterface

include("accumulate.jl")
include("sorting.jl")
include("indexing.jl")
export oneAPIBackend

# precompilation workload (warms up the SPIR-V compilation pipeline)
include("compiler/precompile.jl")
Expand Down
Loading
Loading