diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..6a6e6570d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,21 @@ +stages: + - generate + - test + +generate-pipeline: + stage: generate + image: julia:1.10 + script: + - pip install reframe-hpc + - reframe --ci-generate=${CI_PROJECT_DIR}/pipeline.yml -c ${CI_PROJECT_DIR}/reframe/checks + artifacts: + paths: + - ${CI_PROJECT_DIR}/pipeline.yml + +test-jobs: + stage: test + trigger: + include: + - artifact: pipeline.yml + job: generate-pipeline + strategy: depend \ No newline at end of file diff --git a/reframe/checks/saxpy.py b/reframe/checks/saxpy.py new file mode 100644 index 000000000..9814b0e50 --- /dev/null +++ b/reframe/checks/saxpy.py @@ -0,0 +1,44 @@ +import reframe as rfm +import reframe.utility.sanity as sn + +# Requires a path +class JuliaTest(rfm.RegressionTest): + executable = 'julia' + executable_opts = ['--project=.'] + tags = {'julia'} + build_system = 'CustomBuild' + + julia_script = '' + julia_script_opts = [] + + @run_before('compile') + def setup_build(self): + self.build_system.commands = [ + 'julia --project=. -e "import Pkg; Pkg.resolve()"', + 'julia --project=. -e "import Pkg; Pkg.instantiate()"', + ] + + @run_before('run') + def set_executable_opts(self): + self.executable_opts.append(self.julia_script) + self.executable_opts.extend(self.julia_script_opts) + + +@rfm.simple_test +class saxpy_test(JuliaTest): + valid_systems = ['*'] + valid_prog_environs = ['*'] + + julia_script = 'saxpy.jl' + + @sanity_function + def validate(self): + return sn.assert_found(r'Solution Validates', self.stdout) + + @performance_function('MB/s') + def copy_bw(self): + return sn.extractsingle(r'Copy:\s+(\S+)', self.stdout, 1, float) + + @performance_function('MB/s') + def saxpy_bw(self): + return sn.extractsingle(r'Saxpy:\s+(\S+)', self.stdout, 1, float) diff --git a/reframe/checks/src/Project.toml b/reframe/checks/src/Project.toml new file mode 100644 index 000000000..613cef96b --- /dev/null +++ b/reframe/checks/src/Project.toml @@ -0,0 +1,3 @@ +[deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" diff --git a/reframe/checks/src/saxpy.jl b/reframe/checks/src/saxpy.jl new file mode 100644 index 000000000..673c2a179 --- /dev/null +++ b/reframe/checks/src/saxpy.jl @@ -0,0 +1,46 @@ +using BenchmarkTools +using KernelAbstractions +using Random + +@kernel function copy_kernel!(Z, @Const(X)) + I = @index(Global) + @inbounds Z[I] = X[I] +end + +@kernel function saxpy_kernel!(Z, a, @Const(X), @Const(Y)) + I = @index(Global) + @inbounds Z[I] = a * X[I] + Y[I] +end + +# TODO: Parse cmdline args +T = Float16 +N = 1048576 +BACKEND = CPU() + +res_copy = @benchmark begin + kernel = copy_kernel!($BACKEND) + kernel(Z, X, ndrange = size(Z)) + synchronize($BACKEND) +end setup = ( + X = rand!(KernelAbstractions.zeros($BACKEND, $T, $N)); + Z = KernelAbstractions.zeros($BACKEND, $T, $N) +) + +res_saxpy = @benchmark begin + kernel = saxpy_kernel!($BACKEND) + kernel(Z, convert($T, 2.0), X, Y, ndrange = size(Z)) + synchronize($BACKEND) +end setup = ( + X = rand!(KernelAbstractions.zeros($BACKEND, $T, $N)); + Y = rand!(KernelAbstractions.zeros($BACKEND, $T, $N)); + Z = KernelAbstractions.zeros($BACKEND, $T, $N) +) + +bytes_saxpy = 3 * sizeof(T) * N # num bytes transferred in SAXPY +bytes_copy = 2 * sizeof(T) * N # num bytes transferred in copy +time_saxpy = minimum(res_saxpy).time +time_copy = minimum(res_copy).time + +println("Copy: ", bytes_copy / time_copy) +println("Saxpy: ", bytes_saxpy / time_saxpy) +println("Solution Validates")