Skip to content
Merged
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
27 changes: 14 additions & 13 deletions src/pocl/device/quirks.jl
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
macro print_and_throw(args...)
# throw a device-side exception of type `name`, printing the type and `reason`
macro gputhrow(name::String, reason::String)
return quote
@println "ERROR: " $(args...) "."
@println "ERROR: " $name ": " $reason "."
throw(nothing)
end
end

# math.jl
@device_override @noinline Base.Math.throw_complex_domainerror(f::Symbol, x) =
@print_and_throw "This operation requires a complex input to return a complex result"
@gputhrow "DomainError" "This operation requires a complex input to return a complex result"
@device_override @noinline Base.Math.throw_exp_domainerror(x) =
@print_and_throw "Exponentiation yielding a complex result requires a complex argument"
@gputhrow "DomainError" "Exponentiation yielding a complex result requires a complex argument"

# intfuncs.jl
@device_override @noinline Base.throw_domerr_powbysq(::Any, p) =
@print_and_throw "Cannot raise an integer to a negative power"
@gputhrow "DomainError" "Cannot raise an integer to a negative power"
@device_override @noinline Base.throw_domerr_powbysq(::Integer, p) =
@print_and_throw "Cannot raise an integer to a negative power"
@gputhrow "DomainError" "Cannot raise an integer to a negative power"
@device_override @noinline Base.throw_domerr_powbysq(::AbstractMatrix, p) =
@print_and_throw "Cannot raise an integer to a negative power"
@gputhrow "DomainError" "Cannot raise an integer to a negative power"

# checked.jl
@device_override @noinline Base.Checked.throw_overflowerr_binaryop(op, x, y) =
@print_and_throw "Binary operation overflowed"
@gputhrow "OverflowError" "Binary operation overflowed"

# boot.jl
@device_override @noinline Core.throw_inexacterror(f::Symbol, ::Type{T}, val) where {T} =
@print_and_throw "Inexact conversion"
@gputhrow "InexactError" "Inexact conversion"

# abstractarray.jl
@device_override @noinline Base.throw_boundserror(A, I) =
@print_and_throw "Out-of-bounds array access"
@gputhrow "BoundsError" "Out-of-bounds array access"

# trig.jl
@device_override @noinline Base.Math.sincos_domain_error(x) =
@print_and_throw "sincos(x) is only defined for finite x."
@gputhrow "DomainError" "sincos(x) is only defined for finite x"

# diagonal.jl
# XXX: remove when we have malloc
Expand All @@ -43,7 +44,7 @@ end
# if i == j
# @inbounds D.diag[i] = v
# elseif !iszero(v)
# @print_and_throw "cannot set off-diagonal entry to a nonzero value"
# @gputhrow "ArgumentError" "cannot set off-diagonal entry to a nonzero value"
# end
# return v
# end
Expand All @@ -52,6 +53,6 @@ end
# XXX: remove when we have malloc
@device_override @inline function Base.getindex(x::Number, I::Integer...)
@boundscheck all(isone, I) ||
@print_and_throw "Out-of-bounds access of scalar value"
@gputhrow "BoundsError" "Out-of-bounds access of scalar value"
x
end
Loading