-
Notifications
You must be signed in to change notification settings - Fork 218
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
Rationals behave badly #118
Comments
The stacktraces are actually quite revealing:
All exception related:
So the type itself is fine, it's just that we have a hard time lowering the exception paths. CUDAnative already contains quite some hacks to deal with such functions, but that's for the actual throwing (i.e. it shouldn't be dynamically dispatching). The |
Unfortunately the nastiness happens in the inner constructor of |
A related observation. julia> v = CuVector{Rational{Int64}}([1//2, 2//3, 3//4])
3-element CuArray{Rational{Int64}, 1, CUDA.DeviceMemory}:
1//2
2//3
3//4
julia> v .+ 1
3-element CuArray{Rational{Int64}, 1, CUDA.DeviceMemory}:
3//2
5//3
7//4
julia> v .- 1
3-element CuArray{Rational{Int64}, 1, CUDA.DeviceMemory}:
-1//2
-1//3
-1//4
julia> v .* 2
3-element CuArray{Rational{Int64}, 1, CUDA.DeviceMemory}:
1
4//3
3//2
julia> v .^ 2
3-element CuArray{Rational{Int64}, 1, CUDA.DeviceMemory}:
1//4
4//9
9//16
julia> v ./ 2
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#34#36")(::CUDA.CuKernelContext, ::CuDeviceVector{…}, ::Base.Broadcast.Broadcasted{…}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to __throw_rational_argerror_typemin(T) @ Base rational.jl:20)
Stacktrace:
...
julia> v .// 2
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#34#36")(::CUDA.CuKernelContext, ::CuDeviceVector{…}, ::Base.Broadcast.Broadcasted{…}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to __throw_rational_argerror_typemin(T) @ Base rational.jl:20)
Stacktrace:
...
julia> v .+ v
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#34#36")(::CUDA.CuKernelContext, ::CuDeviceVector{…}, ::Base.Broadcast.Broadcasted{…}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to __throw_rational_argerror_zero(T) @ Base rational.jl:32)
Stacktrace:
... |
These have been fixed by #2403 |
Rationals do not behave well inside
CuArray
s.Not sure there's much to do about this, except implement a simpler Rational type:
The text was updated successfully, but these errors were encountered: