Reja: Kirish Asosiy Openmp direktivalari


#pragma omp parallel for if(parallelism_enabled) for(int c=0; c


Download 57.5 Kb.
bet4/4
Sana20.12.2022
Hajmi57.5 Kb.
#1035231
1   2   3   4
Bog'liq
Kompyuter arxitekturasi

#pragma omp parallel for if(parallelism_enabled) for(int c=0; c
handle(c);
ushbu holatda parallelism_enabled 0 ga teng va sikl bir marta bajariladi
for direktivasi forsiklini bir nechta oqimlarga ajiratadi:
#pragma omp for
for(int n=0; n<10; ++n)
{
printf(" %d", n);
}
printf(".n");
Ushbu tsikl 0 dan 9 gacha bo'lgan sonlarni aniq bir marta chiqaradi. Biroq, ularni olib chiqish tartibi noma'lum. Masalan, bunday bo'lishi mumkin: 0 5 6 7 18
2 3 4 9
Vektorni matritsaga gorizantal lenta(satr) bo’ylab ko’paytiruvchi C++ tilidagi funksiya quyidagichabbo’ladi:
ParallelResultCalculation(double* pMatrix, double* pVector, double* pResult, intSize)
{
int i, j;
#pragma omp paralell for private (j)
for (i=0; i
{ for (j=0; j
pResult[i] +=pMatrix[i*Size+j]*pVector[j];
}
}
Vektorni matritsaga vertikal lenta (ustun) bo’ylab ko’paytiruvchi C++ tilidagi funksiya quyidagicha bo’ladi:
ParallelResultCalculation(double* pMatrix, double* pVector, double* pResult, intSize)
{ int i, j;
for (i=0; i
for (j=0; j
pResult[i] += pMatrix[i*Size+j]*pVector[j];
}
}
Download 57.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling