Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
push:
branches:
- main
tags: ['*']
pull_request:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.0'
- '1.8'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Manifest.toml
*.sif
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 brooks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 19 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name = "spectralGPU"
uuid = "1f941c8d-9269-406b-be03-2a5a5e88bc1c"
authors = ["brooks"]
version = "1.0.0-DEV"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
LazyGrids = "7031d0ef-c40d-4431-b2f8-61a8d2f650db"

[compat]
CUDA = "4"
julia = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# spectralGPU

[![Build Status](https://github.com/vanillabrooks/spectralGPU.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/vanillabrooks/spectralGPU.jl/actions/workflows/CI.yml?query=branch%3Amain)
20 changes: 20 additions & 0 deletions base.apptainer
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Bootstrap: docker
From: ubuntu:20.04

%files
./ /spectralGPU

%post
rm /bin/sh && ln -s /bin/bash /bin/sh

apt update -y && apt upgrade -y
apt install -y curl libssl-dev

curl -fsSL https://install.julialang.org | sh -s -- --yes

. /root/.profile

julia --version

%apprun distribute
echo "hello!"
67 changes: 67 additions & 0 deletions benches/cpu_gpu.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
include("../src/spectralGPU.jl");
using .spectralGPU: mesh, fft, markers, initial_condition, state, config, solver, Integrate

using CUDA
using BenchmarkTools

#########
######### GPU benchmark
#########

N = 128
begin
local parallel = markers.SingleThreadGPU()

local K = mesh.wavenumbers_gpu(N)
local cfg = config.taylor_green_validation()
local st = state.create_state_gpu(N, K, cfg)
local msh = mesh.new_mesh(N)
local ic = markers.TaylorGreen()

local U = CuArray(zeros(N, N, N, 3))
local U_hat = CuArray(ComplexF64.(zeros(K.kn, N, N, 3)))
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark Integrate.integrate(
$parallel,
$K,
$cfg,
$st,
$U,
$U_hat,
)

println("GPU full solver integration")
display(r)
println("\n");
end

#########
######### CPU benchmark
#########

begin
local parallel = markers.SingleThreadCPU()

local K = mesh.wavenumbers(N)
local cfg = config.taylor_green_validation()
local st = state.create_state(N, K, cfg)
local msh = mesh.new_mesh(N)
local ic = markers.TaylorGreen()

local U = zeros(N, N, N, 3)
local U_hat = ComplexF64.(zeros(K.kn, N, N, 3))
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark Integrate.integrate(
$parallel,
$K,
$cfg,
$st,
$U,
$U_hat,
)

println("CPU full solver integration")
display(r)
end
39 changes: 39 additions & 0 deletions benches/cross.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
include("../src/spectralGPU.jl");
using .spectralGPU: mesh, fft, markers, initial_condition, state, config, solver, Integrate

using CUDA
using BenchmarkTools

N = 64

begin
local parallel = markers.SingleThreadGPU()
local re = 40.
local K = mesh.wavenumbers_gpu(N)
local cfg = config.create_config(N, re, 0.00001)
local st = state.create_state_gpu(N, K, cfg)
local U = CuArray(zeros(N, N, N, 3))
local U_hat = CuArray(ComplexF64.(zeros(K.kn, N, N, 3)))

r = @benchmark solver.cross!($parallel, $U, $st.curl; out = $st.dU)

println("GPU cross")
display(r)
println("")
end

begin
local parallel = markers.SingleThreadCPU()
local re = 40.
local K = mesh.wavenumbers(N)
local cfg = config.create_config(N, re, 0.00001)
local st = state.create_state(N, K, cfg)
local U = zeros(N, N, N, 3)
local U_hat = ComplexF64.(zeros(K.kn, N, N, 3))

r = @benchmark solver.cross!($parallel, $U, $st.curl; out = $st.dU)

println("CPU cross")
display(r)
println("")
end
37 changes: 37 additions & 0 deletions benches/curl.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include("../src/spectralGPU.jl");
using .spectralGPU: mesh, fft, markers, initial_condition, state, config, solver, Integrate

using CUDA
using BenchmarkTools

N = 64

begin
local parallel = markers.SingleThreadGPU()
local re = 40.
local K = mesh.wavenumbers_gpu(N)
local cfg = config.create_config(N, re, 0.00001)
local st = state.create_state_gpu(N, K, cfg)
local U_hat = CuArray(ComplexF64.(zeros(K.kn, N, N, 3)))

r = @benchmark solver.curl!($parallel, $K, $U_hat; out = $st.curl)

println("GPU curl")
display(r)
println("")
end

begin
local parallel = markers.SingleThreadCPU()
local re = 40.
local K = mesh.wavenumbers(N)
local cfg = config.create_config(N, re, 0.00001)
local st = state.create_state(N, K, cfg)
local U_hat = ComplexF64.(zeros(K.kn, N, N, 3))

r = @benchmark solver.curl!($parallel, $K, $U_hat; out = $st.curl)

println("CPU curl")
display(r)
println("")
end
99 changes: 99 additions & 0 deletions benches/fft.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
include("../src/spectralGPU.jl");
using .spectralGPU: mesh, fft, markers, initial_condition, state, config, solver, Integrate

using CUDA
using BenchmarkTools

#########
######### GPU (forward) benchmark
#########

N = 64

begin
parallel = markers.SingleThreadGPU()

K = mesh.wavenumbers_gpu(N)

U = CuArray(zeros(N, N, N, 3))
U_hat = CuArray(ComplexF64.(zeros(K.kn, N, N, 3)))

msh = mesh.new_mesh(N)
ic = markers.TaylorGreen()
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark @views fft.fftn_mpi!($parallel, $U[:, :, :, 1], $U_hat[:, :, :, 1])

println("gpu forward FFT")
display(r)
println("")
end

#########
######### CPU (forward) benchmark
#########

begin
parallel = markers.SingleThreadCPU()

K = mesh.wavenumbers(N)

U = zeros(N, N, N, 3)
U_hat = ComplexF64.(zeros(K.kn, N, N, 3))

msh = mesh.new_mesh(N)
ic = markers.TaylorGreen()
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark @views fft.fftn_mpi!($parallel, $U[:, :, :, 1], $U_hat[:, :, :, 1])

println("cpu forward FFT")
display(r)
println("")
end

#########
######### GPU (inverse) benchmark
#########

begin
parallel = markers.SingleThreadGPU()

K = mesh.wavenumbers_gpu(N)

U = CuArray(zeros(N, N, N, 3))
U_hat = CuArray(ComplexF64.(zeros(K.kn, N, N, 3)))

msh = mesh.new_mesh(N)
ic = markers.TaylorGreen()
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark @views fft.ifftn_mpi!($parallel, $K, $U_hat[:, :, :, 1], $U[:, :, :, 1])

println("gpu inverse FFT")
display(r)
println("")
end

#########
######### CPU (inverse) benchmark
#########

begin
parallel = markers.SingleThreadCPU()

K = mesh.wavenumbers(N)

U = zeros(N, N, N, 3)
U_hat = ComplexF64.(zeros(K.kn, N, N, 3))

msh = mesh.new_mesh(N)
ic = markers.TaylorGreen()
initial_condition.setup_initial_condition(parallel, ic, msh, U, U_hat)

r = @benchmark @views fft.ifftn_mpi!($parallel, $K, $U_hat[:, :, :, 1], $U[:, :, :, 1])

println("cpu inverse FFT")
display(r)
println("")
end
Loading