Kompyuter injiniringi ”


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


Download 34 Kb.
bet3/3
Sana22.04.2023
Hajmi34 Kb.
#1381347
1   2   3
Bog'liq
openmp paket imkoniyatlari

#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 34 Kb.

Do'stlaringiz bilan baham:
1   2   3




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