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

Test all storage modes #314

Merged
merged 10 commits into from
Mar 12, 2024
Merged

Conversation

christiangnrd
Copy link
Contributor

@christiangnrd christiangnrd commented Mar 11, 2024

Addresses #312 (comment) and closes #312.

@@ -170,14 +181,16 @@ end

function Base.unsafe_convert(::Type{MtlPointer{T}}, x::MtlArray) where {T}
buf = x.data[]
synchronize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we need to synchronize here. MtlPointers will only be used on device.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this the kernelabstractions copyto test fails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before #305 it worked without a sync.

Base.pointer(x::MtlArray{T}) where {T} = Base.unsafe_convert(MtlPointer{T}, x)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem is, that pointer(A) might mean device or host pointer. #316 might fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR passes all tests, I suggest we merge this and then you can finish up the fix in #316.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, it's really not acceptable to sync on every pointer conversion, as that would remove almost all opportunity for asynchronous execution (as most GPU operations involve a conversion to a pointer).

Copy link
Member

@tgymnich tgymnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses #312 (comment) but does not fix #312.

it does seem to me like your changes would fix #312

@christiangnrd
Copy link
Contributor Author

it does seem to me like your changes would fix #312

I commented that before I decided to submit the fixes. The gpuarrays/indexing scalar tests are still failing with Shared and Managed storage modes.

.buildkite/pipeline.yml Outdated Show resolved Hide resolved
@christiangnrd
Copy link
Contributor Author

christiangnrd commented Mar 11, 2024

I think everything in this PR is ready to go except isn't it a bit of a code smell for there to be a synchronize() in an unsafe function?

Edit: Looking at the CUDA.jl code, seems like it's normal.

if is_private(x)
throw(ArgumentError("cannot take the CPU address of a $(typeof(x))"))
end
synchronize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be good to port the opportunistic synchronization from CUDA.jl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can that be a separate PR? I don't have time at the moment to look into that and this PR in its current state seems to fix #312 and make CI more robust.

@maleadt maleadt merged commit 4d7e12d into JuliaGPU:main Mar 12, 2024
1 check passed
@christiangnrd christiangnrd deleted the test-storagemodes branch March 24, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reductions don't work on Shared Arrays
3 participants