diff --git a/docker-compose-test.yml b/docker-compose-test.yml new file mode 100644 index 0000000..043ad8c --- /dev/null +++ b/docker-compose-test.yml @@ -0,0 +1,109 @@ +services: + slurmfrontend: + build: + context: ./frontend + dockerfile: ./Dockerfile + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/frontend:latest + container_name: spack-stack-frontend + hostname: slurmfrontend + user: admin + volumes: + - home-vol:/home/admin + - opt-vol:/opt + - ./test:/home/admin/test + ports: + - 8888:8888 + slurmmaster: + build: + context: ./master + dockerfile: ./Dockerfile + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/master:latest + container_name: spack-stack-master + hostname: slurmmaster + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_CPUS_ON_NODE=8 + ports: + - 6817:6817 + - 6818:6818 + - 6819:6819 + slurmnode1: + build: + context: ./node + dockerfile: ./Dockerfile + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest + container_name: spack-stack-node1 + hostname: slurmnode1 + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_NODENAME=slurmnode1 + - SLURM_CPUS_ON_NODE=8 + links: + - slurmmaster + slurmnode2: + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest + container_name: spack-stack-node2 + hostname: slurmnode2 + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_NODENAME=slurmnode2 + - SLURM_CPUS_ON_NODE=8 + links: + - slurmmaster + slurmnode3: + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest + container_name: spack-stack-node3 + hostname: slurmnode3 + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_NODENAME=slurmnode3 + - SLURM_CPUS_ON_NODE=8 + links: + - slurmmaster + slurmnode4: + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest + container_name: spack-stack-node4 + hostname: slurmnode4 + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_NODENAME=slurmnode4 + - SLURM_CPUS_ON_NODE=8 + links: + - slurmmaster + slurmnode5: + image: ghcr.io/noaa-gsl/dockerspackstackslurmcluster/node:latest + container_name: spack-stack-node5 + hostname: slurmnode5 + user: admin + volumes: + - home-vol:/home/admin:nocopy + - opt-vol:/opt:ro + - ./test:/home/admin/test + environment: + - SLURM_NODENAME=slurmnode5 + - SLURM_CPUS_ON_NODE=8 + links: + - slurmmaster +volumes: + home-vol: + opt-vol: diff --git a/test/hello.baseline b/test/hello.baseline new file mode 100644 index 0000000..de32800 --- /dev/null +++ b/test/hello.baseline @@ -0,0 +1,7 @@ +Hello world from host slurmnode1, rank 0 out of 6 +Hello world from host slurmnode1, rank 1 out of 6 +Hello world from host slurmnode2, rank 2 out of 6 +Hello world from host slurmnode2, rank 3 out of 6 +Hello world from host slurmnode3, rank 4 out of 6 +Hello world from host slurmnode3, rank 5 out of 6 +foo diff --git a/test/mpi_hello.f90 b/test/mpi_hello.f90 new file mode 100644 index 0000000..e9a0ef0 --- /dev/null +++ b/test/mpi_hello.f90 @@ -0,0 +1,50 @@ +program mpi_hello + + use iso_fortran_env, only : output_unit + use mpi + + integer :: error + integer :: world_size, world_rank, name_len, i + character(len=MPI_MAX_PROCESSOR_NAME) :: host_name + character(len=6) :: rank + character(len=6) :: size + + ! Initialize the MPI environment + call MPI_Init(error) + + ! Get the number of processes + call MPI_Comm_size(MPI_COMM_WORLD, world_size, error) + write(size,'(I6)') world_size + + ! Get the rank of the process + call MPI_Comm_rank(MPI_COMM_WORLD, world_rank, error) + write(rank,'(I6)') world_rank + + ! Get the name of the processor + call MPI_Get_processor_name(host_name, name_len, error) + + do i=0, world_size - 1 + + call MPI_Barrier(MPI_COMM_WORLD, error) + + if (i==world_rank) then + + ! Print off a hello world message + write(*,"(A, A, A, A, A, A)") "Hello world from host ", & + TRIM(host_name), & + ", rank ", & + TRIM(ADJUSTL(rank)), & + " out of ", & + TRIM(ADJUSTL(size)) + + ! Flush stdout + flush(output_unit) + + end if + + end do + + ! Finalize the MPI environment. + call MPI_Finalize(error) + +end program mpi_hello diff --git a/test/test_hello.sh b/test/test_hello.sh new file mode 100755 index 0000000..ab950c5 --- /dev/null +++ b/test/test_hello.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +module use /opt/spack-stack/envs/unified-env/install/modulefiles/Core +module load stack-gcc +module load stack-openmpi +module load stack-python + +mpif90 -o hello.exe mpi_hello.f90 +srun -N 3 --tasks-per-node=2 hello.exe | sort > hello.out + +diff hello.out hello.baseline