# Intel oneAPI :::success 1. 載入 編譯器環境 ``` [user@ilgn01 ~]$ ml load intel/2024_01_46 [user@ilgn01 ~]$ ml list Currently Loaded Modules: 1) intel/2024_01_46 ``` 2. 確認載入的編譯器 ``` [user@ilgn01 ~]$ whereis mpicc mpicc: /pkg/compiler/intel/2024/mpi/2021.11/bin/mpicc ``` 3. 撰寫MPI程式碼 (此以hello.c 為例) ``` [user@ilgn01 ~]$ vi hello.c #include <mpi.h> #include <stdio.h> int main(int argc, char** argv) { MPI_Init(NULL, NULL); int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); char processor_name[MPI_MAX_PROCESSOR_NAME]; int name_len; MPI_Get_processor_name(processor_name, &name_len); printf("Hello world from processor %s, rank %d out of %d processors\n", processor_name, world_rank, world_size); MPI_Finalize(); } ``` 4. 使用mpicc編譯hello.c ``` [user@ilgn01 ~]$ mpicc -o hello ./hello.c ``` 5. 撰寫Slurm Job (以job.sh為例) ``` [user@ilgn01 ~]$ vi job.sh #!/bin/bash #SBATCH --account=GOVXXXXX # Project Name #SBATCH -J test # Job name #SBATCH -N 2 # Total number of nodes requested #SBATCH -n 224 # Total number of mpi tasks requested #SBATCH -t 01:30:00 # Run time (hh:mm:ss) - 1.5 hours #SBATCH --partition=XXXX # Partition Name #SBATCH -o job.%j.log # (-o) Path to the standard output file #SBATCH -e job.%j.err # (-e) Path to the standard error file #SBATCH --mail-type=END,FAIL # Mail events (NONE, BEGIN, END, FAIL, ALL) #SBATCH --mail-user=user@example.com # Where to send mail. Set this to your email address module purge module load intel/2024_01_46 mpiexec ./hello ``` 6. 提交Slurm Job ``` [user@ilgn01 ~]$ sbatch job.sh Submitted batch job 14098 ``` 7. 查看執行輸出的結果 ``` [user@ilgn01 ~]$ cat job.14098.out Hello world from processor icpnp302, rank 118 out of 150 processors Hello world from processor icpnp302, rank 119 out of 150 processors Hello world from processor icpnp302, rank 120 out of 150 processors Hello world from processor icpnp301, rank 0 out of 150 processors Hello world from processor icpnp301, rank 1 out of 150 processors Hello world from processor icpnp301, rank 107 out of 150 processors Hello world from processor icpnp301, rank 108 out of 150 processors Hello world from processor icpnp301, rank 109 out of 150 processors Hello world from processor icpnp301, rank 110 out of 150 processors ... ``` **<font color="blue">備註:如何撰寫腳本請移至[提交與管理Job範例](https://man.twcc.ai/@f1-manual/slurm_job_example)觀看內容</font>** :::