#include #define ARR_SIZE 600 #define STEP_SIZE 100 #include int main() { /* Computing Array sum using tasks */ int i; int sum = 0; #pragma omp parallel { int a[ARR_SIZE]; #pragma omp for for (i = 0; i < ARR_SIZE; i += STEP_SIZE) { int j, start = i, end = i + STEP_SIZE - 1; printf("Computing Sum(%d,%d) in thread %d of %d ", start, end, omp_get_thread_num(), omp_get_num_threads()); #pragma omp task { int psum = 0; printf("Task computing Sum(%d,%d) in thread %d of %d ", start, end, omp_get_thread_num(), omp_get_num_threads()); for (j = start; j
what about the cache data that is needed in a certain tast? when tast is free to be executed at any time, the caches might not have required data.
please share the source code
#include
#define ARR_SIZE 600
#define STEP_SIZE 100
#include
int main() {
/* Computing Array sum using tasks */
int i;
int sum = 0;
#pragma omp parallel
{
int a[ARR_SIZE];
#pragma omp for
for (i = 0; i < ARR_SIZE; i += STEP_SIZE) {
int j, start = i, end = i + STEP_SIZE - 1;
printf("Computing Sum(%d,%d) in thread %d of %d
", start, end,
omp_get_thread_num(), omp_get_num_threads());
#pragma omp task
{
int psum = 0;
printf("Task computing Sum(%d,%d) in thread %d of %d
", start, end,
omp_get_thread_num(), omp_get_num_threads());
for (j = start; j