Skip to content

Commit 5141aad

Browse files
authored
nbody readme update (oneapi-src#581)
Updated Nbody with instructions for how to run on Devcloud.
1 parent 701d3d8 commit 5141aad

File tree

1 file changed

+122
-0
lines changed
  • DirectProgramming/DPC++/N-BodyMethods/Nbody

1 file changed

+122
-0
lines changed

DirectProgramming/DPC++/N-BodyMethods/Nbody/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Third party program Licenses can be found here: [third-party-programs.txt](https
2323

2424
## Building the Program for CPU and GPU
2525

26+
### Running Samples In DevCloud
27+
Running samples in the Intel DevCloud requires you to specify a compute node. For specific instructions, jump to [Run the Nbody sample on the DevCloud](#run-nbody-on-devcloud)
28+
2629
### Include Files
2730
The include folder is located at `%ONEAPI_ROOT%\dev-utilities\latest\include` on your development system.
2831

@@ -92,3 +95,122 @@ Below are the default parameters:
9295
# Average Performance : 112.09 +- 0.56002
9396
===============================
9497
Built target run
98+
99+
### Running the Hidden Markov Model sample in the DevCloud<a name="run-nbody-on-devcloud"></a>
100+
1. Open a terminal on your Linux system.
101+
2. Log in to DevCloud.
102+
```
103+
ssh devcloud
104+
```
105+
3. Download the samples.
106+
```
107+
git clone https://github.com/oneapi-src/oneAPI-samples.git
108+
```
109+
110+
4. Change directories to the Hidden Markov Model sample directory.
111+
```
112+
cd ~/oneAPI-samples/DirectProgramming/DPC++/N-bodyMethods/Nbody
113+
```
114+
#### Build and run the sample in batch mode
115+
The following describes the process of submitting build and run jobs to PBS.
116+
A job is a script that is submitted to PBS through the qsub utility. By default, the qsub utility does not inherit the current environment variables or your current working directory. For this reason, it is necessary to submit jobs as scripts that handle the setup of the environment variables. In order to address the working directory issue, you can either use absolute paths or pass the -d \<dir\> option to qsub to set the working directory.
117+
118+
#### Create the Job Scripts
119+
1. Create a build.sh script with your preferred text editor:
120+
```
121+
nano build.sh
122+
```
123+
2. Add this text into the build.sh file:
124+
```
125+
source /opt/intel/inteloneapi/setvars.sh > /dev/null 2>&1
126+
mkdir build
127+
cd build
128+
cmake ..
129+
make
130+
```
131+
132+
3. Save and close the build.sh file.
133+
134+
4. Create a run.sh script with with your preferred text editor:
135+
```
136+
nano run.sh
137+
```
138+
139+
5. Add this text into the run.sh file:
140+
```
141+
source /opt/intel/inteloneapi/setvars.sh > /dev/null 2>&1
142+
cd build
143+
make run
144+
```
145+
6. Save and close the run.sh file.
146+
147+
#### Build and run
148+
Jobs submitted in batch mode are placed in a queue waiting for the necessary resources (compute nodes) to become available. The jobs will be executed on a first come basis on the first available node(s) having the requested property or label.
149+
1. Build the sample on a gpu node.
150+
151+
```
152+
qsub -l nodes=1:gpu:ppn=2 -d . build.sh
153+
```
154+
155+
Note: -l nodes=1:gpu:ppn=2 (lower case L) is used to assign one full GPU node to the job.
156+
Note: The -d . is used to configure the current folder as the working directory for the task.
157+
158+
2. In order to inspect the job progress, use the qstat utility.
159+
```
160+
watch -n 1 qstat -n -1
161+
```
162+
Note: The watch -n 1 command is used to run qstat -n -1 and display its results every second. If no results are displayed, the job has completed.
163+
164+
3. After the build job completes successfully, run the sample on a gpu node:
165+
```
166+
qsub -l nodes=1:gpu:ppn=2 -d . run.sh
167+
```
168+
4. When a job terminates, a couple of files are written to the disk:
169+
170+
<script_name>.sh.eXXXX, which is the job stderr
171+
172+
<script_name>.sh.oXXXX, which is the job stdout
173+
174+
Here XXXX is the job ID, which gets printed to the screen after each qsub command.
175+
176+
5. Inspect the output of the sample.
177+
```
178+
cat run.sh.oXXXX
179+
```
180+
You should see output similar to this:
181+
182+
```
183+
Scanning dependencies of target run
184+
===============================
185+
Initialize Gravity Simulation
186+
nPart = 16000; nSteps = 10; dt = 0.1
187+
------------------------------------------------
188+
s dt kenergy time (s) GFLOPS
189+
------------------------------------------------
190+
1 0.1 26.405 0.43625 17.019
191+
2 0.2 313.77 0.02133 348.07
192+
3 0.3 926.56 0.021546 344.59
193+
4 0.4 1866.4 0.02152 345
194+
5 0.5 3135.6 0.021458 346
195+
6 0.6 4737.6 0.021434 346.38
196+
7 0.7 6676.6 0.02143 346.45
197+
8 0.8 8957.7 0.021482 345.6
198+
9 0.9 11587 0.021293 348.68
199+
10 1 14572 0.021324 348.16
200+
201+
# Total Time (s) : 0.62911
202+
# Average Performance : 346.36 +- 1.3384
203+
===============================
204+
Built target run
205+
```
206+
207+
6. Remove the stdout and stderr files and clean-up the project files.
208+
```
209+
rm build.sh.*; rm run.sh.*; make clean
210+
```
211+
7. Disconnect from the Intel DevCloud.
212+
```
213+
exit
214+
```
215+
### Build and run additional samples
216+
Several sample programs are available for you to try, many of which can be compiled and run in a similar fashion to this sample. Experiment with running the various samples on different kinds of compute nodes or adjust their source code to experiment with different workloads.

0 commit comments

Comments
 (0)