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

Add parallel_for API with keyword struct #188

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

PhilipFackler
Copy link
Collaborator

@PhilipFackler PhilipFackler commented Feb 13, 2025

This addresses #179 and #180

@PhilipFackler
Copy link
Collaborator Author

Test this please

@PhilipFackler PhilipFackler force-pushed the kw-struct branch 2 times, most recently from 30e3902 to 4c166a9 Compare February 14, 2025 15:25
@PhilipFackler
Copy link
Collaborator Author

Test this please

@PhilipFackler
Copy link
Collaborator Author

Test this please

@PhilipFackler
Copy link
Collaborator Author

Test this please

@PhilipFackler
Copy link
Collaborator Author

Test this please


@kwdef mutable struct LaunchSpec{Backend}
stream = default_stream(Backend)
threads = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious why some are typed explicitly and some are not. FYI, this will default to Int64.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the type of the stream is determined by the backend. Threads can be either an Integer or a tuple of 2 or 3 integers. same with blocks

@@ -93,10 +128,10 @@ end
end

@testset "reduce" begin
a = JACC.array([1 for i=1:10])
a = JACC.array([1 for i in 1:10])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe for later, do a formatting only PR. It seems these are not functional changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I did formatting as I was going with this one, so it applied to changes from prior to this PR.

A = JACC.ones(Float32, N, N, N)
B = JACC.ones(Float32, N, N, N)
C = JACC.zeros(Float32, N, N, N)
JACC.parallel_for(JACC.launch_spec(; threads = (4, 4, 4)),
Copy link
Collaborator

@williamfgc williamfgc Feb 14, 2025

Choose a reason for hiding this comment

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

I guess this is required to be a first argument since we are using Varargs. Another overloaded version, for later, could be similar to CUDA.jl (since AMDGPU.jl now follows it):
JACC.@lauch_spec threads = (16, 16) blocks = (1,1) sync=false JACC.parallel_for(N, f, x...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll open an issue for this feature.

Copy link
Collaborator

@williamfgc williamfgc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @PhilipFackler . Remove the WIP when ready.

@PhilipFackler PhilipFackler changed the title WIP: Add parallel_for API with keyword struct Add parallel_for API with keyword struct Feb 14, 2025
@PhilipFackler
Copy link
Collaborator Author

@williamfgc ready. And we can just close the other PR.

@williamfgc williamfgc merged commit 43ef00f into JuliaORNL:main Feb 14, 2025
6 checks passed
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.

2 participants