# include <stdio.h>int main(){printf("Hello World!!");return 0;}
#!/bin/bash#SBATCH -J helloWorldC#SBATCH -o helloWorldC.txt#SBATCH -p compute1#SBATCH -t 00:02:00#SBATCH -N 1#SBATCH -n 1./helloCOut
# include <iostream>using namespace std;int main(){cout<<"Hello World!!";return 0;}
#!/bin/bash#SBATCH -J helloWorldCPP#SBATCH -o helloWorldCPP.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1./helloCPPOut
Listing 5: Sample Fortran Program ( ../documentation/serial_jobs/serialf/GNU/hello_world.f90)program helloprint *, 'Hello, World!!'end program hello
Listing 6: Batch Job Script for Fortran code (../ documentation/serial_jobs/serialf/GNU/helloworldf.slurm)#!/bin/bash#SBATCH -J helloWorldF90#SBATCH -o helloWorldF90.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1./helloF90Out
print('Hello World!!')
#!/bin/bash#SBATCH -J helloWorldpy#SBATCH -o helloWorldpy.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1python3 hello_world.py
#include <mpi.h>#include <stdio.h>int main(int argc, char** argv) {// Initialize the MPI environmentMPI_Init(NULL, NULL);// Get the number of processesint world_size;MPI_Comm_size(MPI_COMM_WORLD, &world_size);// Get the rank of the processint world_rank;MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);// Get the name of the processorchar processor_name[MPI_MAX_PROCESSOR_NAME];int name_len;MPI_Get_processor_name(processor_name, &name_len);// Print off a hello world messageprintf("Hello world from processor %s, rank %d out of %d processors\n",processor_name, world_rank, world_size);// Finalize the MPI environment.MPI_Finalize();return 0;}
#!/bin/bash#SBATCH -J helloCMPIOut#SBATCH -o helloCMPIOut.txt#SBATCH -p compute1#SBATCH -t 00:10:00#SBATCH -N 2#SBATCH -n 12mpirun -np 12 ./helloCMPIOut
Listing 11: Sample MPI program with C++ (.. /documentation/mpi_jobs/mpicpp/hello_world.cpp)#include <mpi.h>#include <iostream>using namespace std;int main(int argc, char** argv) {// Initialize the MPI environmentMPI_Init(NULL, NULL);// Get the number of processesint world_size;MPI_Comm_size(MPI_COMM_WORLD, &world_size);// Get the rank of the processint world_rank;MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);// Get the name of the processorchar processor_name[MPI_MAX_PROCESSOR_NAME];int name_len;MPI_Get_processor_name(processor_name, &name_len);// Print off a hello world messagecout<<"Hello World from processor "<<processor_name<<", rank "<<world_rank<<"out of "<<world_size<<"processors\n";// Finalize the MPI environment.MPI_Finalize();return 0;}
#!/bin/bash#SBATCH -J helloWorldCPPMPI#SBATCH -o helloWorldCPPMPI.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 2#SBATCH -n 12mpirun -np 12 ./helloCPPMPIOut
program helloinclude 'mpif.h'call MPI_INIT (ierr)print *, "Hello world"call MPI_FINALIZE (ierr)end program hello
#!/bin/bash#SBATCH -J helloWorldF90MPI#SBATCH -o helloWorldF90MPI.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 2#SBATCH -n 12mpirun -np 12 ./helloF90MPIOut
#include <omp.h>#include <stdio.h>#include <stdlib.h>int main(int argc, char* argv[]){// Beginning of parallel region#pragma omp parallel{printf("Hello World... from thread = %d\n",omp_get_thread_num());}// Ending of parallel regionreturn 0;}
#!/bin/bash#SBATCH -J helloWorldCOpenMP#SBATCH -o helloWorldCOpenMP.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 4export OMP_NUM_THREADS=4./helloCOpenMPOut
Listing 17: Sample OpenMP program in C++ (../documentation/openmp_jobs/openmpcpp/GNU/hello_world.cpp)#include <omp.h>#include <iostream>#include <stdlib.h>using namespace std;int main(int argc, char* argv[]){// Beginning of parallel region#pragma omp parallel{cout<<"Hello World... from thread ="<< omp_get_thread_num();cout<<"\n";}// Ending of parallel regionreturn 0;}
#!/bin/bash#SBATCH -J helloOpenMPCPPOut#SBATCH -o helloOpenMPCPPOut.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 4export OMP_NUM_THREADS=4./helloOpenMPCPPOut
PROGRAM Parallel_Hello_WorldUSE OMP_LIB!$OMP PARALLELprint *,"Hello from process: ", OMP_GET_THREAD_NUM()!$OMP END PARALLELEND
#!/bin/bash#SBATCH -J helloworldfopenmp#SBATCH -o helloworldfopenmp.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 4export OMP_NUM_THREADS=4./helloF90OpenMPOut
#include <stdio.h>#include <cuda.h>#include <stdlib.h>#include <unistd.h>int main(){int count, err;cudaGetDeviceCount(&count);printf("device count = %d\n", count);if(err = cudaSetDevice(count-1)){printf("cudaSetDevice error, %d\n", err);}return 0;}
#!/bin/bash#SBATCH -J helloWorldCcuda#SBATCH -o helloWorldCcuda.txt#SBATCH -p gpu1v100#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1./helloCcudaOut
#!/bin/bash#SBATCH -J helloWorldCcuda#SBATCH -o helloWorldCcuda.txt#SBATCH -p gpu2v100#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1#SBATCH --gres=gpu:v100:0./helloWorldCcuda
#include <iostream>#include <cuda.h>#include <stdlib.h>#include <unistd.h>using namespace std;int main(){int count, err;cudaGetDeviceCount(&count);cout<<"device count = "<<count<<"\n";if(err = cudaSetDevice(count-1)){cout<<"cudaSetDevice error, "<<err<<"\n";}return 0;}
#!/bin/bash#SBATCH -J helloWorldCPPcuda#SBATCH -o helloWorldCPPcuda.txt#SBATCH -p gpu1v100#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1./helloWorldCPPcuda
#!/bin/bash#SBATCH -J helloWorldCPPcuda#SBATCH -o helloWorldCPPcuda.txt#SBATCH -p gpu2v100#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1#SBATCH --gres=gpu:v100:0./helloWorldCPPcuda
program cpydatause cudaforimplicit noneinteger, parameter :: n = 256real :: a(n), b(n)real, device::a_d(n), b_d(n)a = 1.0a_d = ab_d = a_db = b_dif (all(a==b)) thenwrite(,) 'Test Passed'elsewrite(,) 'Test Failed'end ifend program cpydata
#!/bin/bash#SBATCH -J helloWorldFcuda#SBATCH -o helloWorldFcuda.txt#SBATCH -p gpu1v100#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1./helloWorldFcuda
#!/bin/bash#SBATCH -J program_name#SBATCH -o program_name.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 1ml gnu8/8.3.0ml R/3.6.1Rscripthello_world.r
# include <stdio.h># include<stdlib.h>int main(int argc, char *argv[]){int n = atoi( argv[1]);for(int i=1;i<=n;i++){printf("Hello World!!: %d \n",i);}return 0;}
#!/bin/bash#SBATCH -J helloWorldCm#SBATCH -o helloWorldCm.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH -n 5./helloCOut1&./helloCOut2&./helloCOut3&./helloCOut4&./helloCOut5
#include <mpi.h>#include <stdio.h>int main(int argc, char** argv) {// Initialize the MPI environmentMPI_Init(NULL, NULL);// Get the number of processesint world_size;MPI_Comm_size(MPI_COMM_WORLD, &world_size);// Get the rank of the processint world_rank;MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);// Get the name of the processorchar processor_name[MPI_MAX_PROCESSOR_NAME];int name_len;MPI_Get_processor_name(processor_name, &name_len);// Print off a hello world messageprintf("Hello world from processor %s, rank %d out of %d processors\n",processor_name, world_rank, world_size);// Finalize the MPI environment.MPI_Finalize();return 0;}
#include <mpi.h>#include <stdio.h>int main(int argc, char** argv) {// Initialize the MPI environmentMPI_Init(NULL, NULL);// Get the number of processesint world_size;MPI_Comm_size(MPI_COMM_WORLD, &world_size);// Get the rank of the processint world_rank;MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);// Get the name of the processorchar processor_name[MPI_MAX_PROCESSOR_NAME];int name_len;MPI_Get_processor_name(processor_name, &name_len);// Print off a hello world messageprintf("Bye world from processor %s, rank %d out of %d processors\n",processor_name, world_rank, world_size);// Finalize the MPI environment.MPI_Finalize();return 0;}
#!/bin/bash#SBATCH -J helloWorldCMPIm#SBATCH -o helloWorldCMPIm.txt#SBATCH -p compute1#SBATCH -t 00:10:00#SBATCH -N 2#SBATCH -n 24mpirun -np 12 ./helloCMPIOut&mpirun -np 12 ./byeCMPIOut
# include <stdio.h># include<stdlib.h>int main(int argc, char *argv[]){int n = atoi( argv[1]);for(int i=1;i<=n;i++){printf("Hello World!!: %d \n",i);}return 0;}
[username@login001]$ cat myout.txt12345
#!/bin/sh#SBATCH -J helloWorldCgnup#SBATCH -o helloWorldCgnup.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH --cpus-per-task=1#SBATCH -n 1ml parallel/20210622parallel --joblog logfilename.txt ./helloCOut{1} :::: myout.txt
#include <stdio.h>#include <math.h>#include <stdlib.h>int main(int argc, char** argv){int n,i;sscanf(argv[1],"%d",&n);printf(" The prime factors of %d are:", n);while (n%2 == 0){n = n/2;}for(i = 3; i <= (int)sqrt(n); i = i+2){while (n%i == 0){printf("%d ", i);n = n/i;}}if (n > 2)printf ("%d", n);printf("\n");return 0;}
[username@login001]$ cat paramfile.txt123456789612345678911234567899123456789512345678471234567941123456892712345789571234689630123457896012346789751235678933124567899813456789201234567892123456784412345679701234568951123457898112346789691235678949123457899312345678971234567898123456789112345679661234568918123457898312346789561235678921124567895513456789371234567895123456789512345678951234567988123456893612345789321234678946123567891312456789241234567896123456789212345678111234567990123456897912345789861678977111123456789612345678911234567899123456789512345678471234567941123456892712345789571234689630123457896012346789751235678933124567899813456789201234567892123456784412345679701234568951123457898112346789691235678949123457899312345678971234567898123456789112345679661234568918123457898312346789561235678921124567895513456789371234567895123456789512345678951234567988123456893612345789321234678946123567891312456789241456789841
#!/bin/sh#SBATCH -J program_name#SBATCH -o program_name.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH --cpus-per-task=1#SBATCH -n 1ml gcc/11.2.0ml parallel/20210722parallel --joblog logfilename.txt ./exefilename {1} :::: paramfile.txt
#!/bin/sh#SBATCH -J program_name#SBATCH -o program_name.txt#SBATCH -p compute1#SBATCH -t 00:05:00#SBATCH -N 1#SBATCH --cpus-per-task=1#SBATCH -n 1ml gnu8/8.3.0ml parallel/20210622parallel --resume-failed --joblog logfilename.txt ./exefilename {1} :::: paramfile.txt