-
Notifications
You must be signed in to change notification settings - Fork 41
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
inputing non-isbits types #128
Comments
You're actually passing a type, while you should be specializing on it instead ( |
thanks for the quick reply. that gives the same error though. i think the fundamental problem is that type conversion is not allowed in a kernel, as the modified function below, which does NOT input a type nor specialize, but rather calls
|
more debugging data, which might or might not be related / informative: outside of the kernel,
|
You are mixing different bug reports in a single issue; please keep them separate (also for questions like this Discourse is better suited).
Works for me: julia> b = rand(Float32, 1)
1-element Vector{Float32}:
0.9079935
julia> sin.(MtlArray(b))
1-element MtlVector{Float32}:
0.78827065
That's because Metal currently does not support exceptions, #69, and assigning a Float32 to an Int array (like you're doing in your kernel) can throw an InexactError. |
thanks for the help, and sorry for the dumb questions. to clarify your previous comment about specializing, that is not expected to work either i guess, right? at least i can't get it to:
so i tried sneaking
only when
i was surprised that setting
but worry that doing so inside the kernel is slow. but i guess that is computed during compilation, not run-time? my original CUDA function, which i'm trying to refactor to Metal (and eventually KernelAbstractions), computes
|
The issue with
As an alternative to function vadd(a, b, c)
function kernel1(a::AbstractVector{T}, b, c) where T
i = thread_position_in_grid_1d()
c[i] = T(a[i]) + T(b[i])
return
end
@metal threads=2 groups=2 kernel1(a, b, c)
end The problems you're getting is just because you're trying to pass actual types, which aren't concrete objects, instead of typevars Julia can specialize on. There's a very big difference between them, even though the syntax looks similar. |
#135 should make |
a simple modification to the example in the README does not work:
i'm hoping we can get this to work, as it works fine with CUDA.jl:
this is with julia 1.8.5, 0-day master of Metal.jl, and an M2 Max
The text was updated successfully, but these errors were encountered: