31 lines
1 KiB
Markdown
31 lines
1 KiB
Markdown
18 Outubro 2023 - #CP
|
|
|
|
## Ex 1
|
|
### a)
|
|
Running the code (first time):
|
|
![[Pasted image 20231018113933.png]]
|
|
|
|
Running the code (second time):
|
|
![[Pasted image 20231018114101.png]]
|
|
|
|
No, since the task scheduling is dependant on the resources available (cpu cores).
|
|
|
|
### b)
|
|
Yes, since the threads do the same task (orderly printing ids) following the orderly creation of threads in the for loop.
|
|
|
|
NOTE: These threads use a fork-join architecture, aka both threads work simultaneously and when one ends, it waits for the other to finish their job to then end both threads and continuing on with the code.
|
|
### c)
|
|
It is dependant on the CPU availability in each clock cycle. A thread, when executed uses
|
|
|
|
## Ex 2
|
|
### 2.1 - \#pragma omp for
|
|
![[Pasted image 20231018115329.png]]
|
|
#### a)
|
|
There is a distribution of literally half the prints to each of the 2 thread created. There is a static distribution of instructions to each thread.
|
|
Thread 0 -> ids 0-49
|
|
Thread 1 -> ids 50-99
|
|
#### b)
|
|
Yes, since it is statically distributed.
|
|
#### c)
|
|
|
|
|