-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `ptrace` support for any `GPUArray` * Add changelog --------- Co-authored-by: Yi-Te Huang <[email protected]>
- Loading branch information
1 parent
3ffdd3d
commit 1f857be
Showing
5 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,33 @@ | ||
module QuantumToolboxGPUArraysExt | ||
|
||
using QuantumToolbox | ||
|
||
import GPUArrays: AbstractGPUArray | ||
import KernelAbstractions | ||
import KernelAbstractions: @kernel, @Const, @index, get_backend, synchronize | ||
|
||
@kernel function tr_kernel!(B, @Const(A)) | ||
# i, j, k = @index(Global, NTuple) | ||
# Atomix.@atomic B[i, j] += A[i, j, k, k] # TODO: use Atomix when it will support Complex types | ||
|
||
i, j = @index(Global, NTuple) | ||
@inbounds B[i, j] = 0 | ||
@inbounds for k in 1:size(A, 3) | ||
B[i, j] += A[i, j, k, k] | ||
end | ||
end | ||
|
||
function QuantumToolbox._map_trace(A::AbstractGPUArray{T,4}) where {T} | ||
B = similar(A, size(A, 1), size(A, 2)) | ||
fill!(B, 0) | ||
|
||
backend = get_backend(A) | ||
kernel! = tr_kernel!(backend) | ||
|
||
kernel!(B, A, ndrange = size(A)[1:2]) | ||
KernelAbstractions.synchronize(backend) | ||
|
||
return B | ||
end | ||
|
||
end |
This file contains 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 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