-
Notifications
You must be signed in to change notification settings - Fork 6
GPU Benchmarks #265
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
Draft
BernhardAhrens
wants to merge
10
commits into
main
Choose a base branch
from
ba/gpu_benchmark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
GPU Benchmarks #265
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eb0bbf4
start fresh
BernhardAhrens 5ada65c
yay speedup when we go wide
BernhardAhrens 1e722f3
two factors depth and width
BernhardAhrens 8f5192f
local dev setup
BernhardAhrens f55824d
works with Metal?
BernhardAhrens f4cbef8
runic
BernhardAhrens d735f21
literate
BernhardAhrens 11484da
comments outside functions for Literate.jl
BernhardAhrens 47c861e
more inline loop comments - map problem?
BernhardAhrens ff46088
leftover
BernhardAhrens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Load the appropriate GPU backend for `MLDataDevices`, independent of machine. | ||
| # | ||
| # Tries the common GPU trigger packages in order: | ||
| # - LuxCUDA -> CUDADevice (NVIDIA) | ||
| # - AMDGPU -> AMDGPUDevice (AMD ROCm) | ||
| # - Metal -> MetalDevice (Apple Silicon) | ||
| # - oneAPI -> oneAPIDevice (Intel) | ||
| # | ||
| # The first backend that is both installed AND functional on this machine | ||
| # is kept. If none are available, we silently fall back to CPU and | ||
| # `gpu_device()` will return a `CPUDevice`. | ||
| # | ||
| # After `include`ing this file, the following are defined in the caller's | ||
| # namespace: | ||
| # - `GPU_BACKEND_PKG` : `Symbol` of the loaded package (or `nothing`) | ||
| # - `GPU_DEVICE_TYPE` : the `MLDataDevices` device type (e.g. `CUDADevice`, | ||
| # or `CPUDevice` as fallback) | ||
|
|
||
| using MLDataDevices | ||
|
|
||
| const _GPU_TRIGGERS = [ | ||
| (:LuxCUDA, :CUDADevice), | ||
| (:AMDGPU, :AMDGPUDevice), | ||
| (:Metal, :MetalDevice), | ||
| (:oneAPI, :oneAPIDevice), | ||
| ] | ||
|
|
||
| function _load_gpu_backend() | ||
| for (pkg, dev) in _GPU_TRIGGERS | ||
| try | ||
| @eval Main using $pkg | ||
| catch err | ||
| @debug "Skipping $pkg (not installed / failed to load)" exception = err | ||
| continue | ||
| end | ||
|
|
||
| # `using $pkg` may load an `MLDataDevices` package extension that | ||
| # adds new methods (e.g. a real `functional(::Type{CUDADevice})`). | ||
| # Those methods live in a newer world age than this function, so | ||
| # we must dispatch via `invokelatest` or we'll get the stale | ||
| # (pre-extension) method that reports `false`. | ||
| DeviceT = Base.invokelatest(getfield, MLDataDevices, dev) | ||
| is_functional = Base.invokelatest(MLDataDevices.functional, DeviceT) | ||
|
|
||
| if is_functional | ||
| @info "GPU backend loaded: $pkg → $dev" | ||
| return pkg, DeviceT | ||
| else | ||
| @warn "$pkg loaded but $dev is not functional on this machine; trying next backend." | ||
| end | ||
| end | ||
|
|
||
| @info "No functional GPU backend found; falling back to CPU." | ||
| return nothing, CPUDevice | ||
| end | ||
|
|
||
| const GPU_BACKEND_PKG, GPU_DEVICE_TYPE = _load_gpu_backend() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| using Pkg | ||
| Pkg.activate("docs") | ||
| Pkg.develop(path = pwd()) | ||
| Pkg.instantiate() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For iterating over a grid of parameters, using
mapwithIterators.productis often more idiomatic and can be clearer than a nested loop inside a list comprehension with abegin...endblock. This approach can make the code for your parameter sweep more concise and readable.