It's UWAweek 47

help5507

This forum is provided to promote discussion amongst students enrolled in CITS5507 High Performance Computing.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 3 articles in this topic
Showing 3 of 148 articles.
Currently 14 other people reading this forum.


 UWA week 33 (2nd semester, week 4) ↓
SVG not supported

Login to reply

👍?
helpful
4:42pm Sat 17th Aug, Zhipeng W.

In this example (in the slide), int main(int argc, char *argv[]) { printf("Openmp running with %d threads\n", omp_get_max_threads()); #pragma omp parallel { printf("Hello World from thread %d\n", omp_get_thread_num()); } return 0; } I ran this on setonix, but get a result shown below: Openmp running with 1 threads Hello World from thread 0 . . . repeat 28 times... Is it correct? but what I expect is 28 threads, then from thread 1,2,3...


 UWA week 34 (2nd semester, week 5) ↓
SVG not supported

Login to reply

👍?
helpful
10:08am Wed 21st Aug, Yao T.

Maybe you could try "omp_set_num_threads" and have a test.


SVG not supported

Login to reply

👍x1
helpful
1:36pm Wed 21st Aug, Abdul M.

Hi, I assume you are running in Setonix using the batch script.

The batch script example shows that you request one server (--node=1) and 28 tasks (--ntasks=28). The ntasks option means you are asking for 28 independent processes with the default number of threads = 1. That's why you will find the program output is "Hello from thread 0" 28 times because it comes from 28 independent processes.

In the slide, it was assumed that you are only running on a single computer, with one process, AND asking for multithreading with four threads. That's why you are seeing different thread numbers.

If you want to achieve the same results with the slide, you can add this line on the batch script before running your program:

...
cc -o test -fopenmp ./test.c

# Add this line
export OMP_NUM_THREADS=4

srun ./test

The output will be 28 processes with four threads each, resulting in 28 x 4 = 112 lines of output. You can see the different thread ID in each process.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy