The primary goal of Tutorial 3 is to equip users with the knowledge and skills to compile and execute various C/C++ applications effectively on Cyclone's compute nodes. By leveraging Cyclone's high-performance infrastructure, users will explore the process of running simple "Hello World" programs across multiple paradigms, including serial execution, parallel computing with OpenMP, distributed computing with MPI, and GPU-accelerated computing with CUDA. This hands-on experience highlights the nuances of using different compilers (GNU and Intel), and how to use the module system, understanding the role of SLURM scripts for job submission, and optimizing resource usage.
Plain C: Save the following as hello.c
:
#include <stdio.h>
int main() {
printf("Hello, World from Cyclone!\n");
return 0;
}
OpenMP: Save the following as hello_openmp.c
:
#include <stdio.h>
#include <omp.h>
int main() {
#pragma omp parallel
{
printf("Hello from thread %d out of %d\n", omp_get_thread_num(), omp_get_num_threads());
}
return 0;
}
MPI: Save the following as hello_mpi.c
:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello from process %d out of %d\n", rank, size);
MPI_Finalize();
return 0;
}
CUDA: Save the following as hello_cuda.cu
:
#include <stdio.h>
__global__ void helloFromGPU() {
printf("Hello, World from GPU thread %d\n", threadIdx.x);
}
int main() {
helloFromGPU<<<1, 10>>>();
cudaDeviceSynchronize();
return 0;
}
Follow Guide 7: Compiling and Running C/C++ Code.
Use sbatch
to submit the generated SLURM scripts. In each submission add the --reservation=edu25
to avoid queuing. For example:
sbatch run_openmp.slurm --reservation=edu25