bo'lgan sonlar sonini 8 ta qatorga o'rnatdik.
eksport OMP_NUM_THREADS = 8
OpenMP-da birinchi kodni ishga tushirish
// OpenMP header
#include
#include
#include
int main(int argc, char* argv[])
{
int nthreads, tid;
// Begin of parallel region
#pragma omp parallel private(nthreads, tid)
{
// Getting thread number
tid = omp_get_thread_num();
printf("Welcome to GFG from thread = %d\n",
tid);
if (tid == 0) {
// Only master thread does this
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n",
nthreads);
}
}
}
Chiqish:
Ushbu dastur turli xil mavzular tomonidan bajariladigan xabarni chop etadi.
Tuzish:
gcc -o gfg -fopenmp geeksforgeeks.c
Ijro etilishi:
./gfg
OpenMP | Salom dunyo dasturi
Old shart:
OpenMP | O'rnatish bo'yicha qo'llanma bilan tanishish
C / C ++ /
Fortran
dasturida
parallel dasturlash OpenMP
yordamida
amalga
oshiriladi.
Ushbu maqolada biz
OpenMP-
dan
foydalanib parallel
Hello World
dasturini
qanday yaratishni bilib olamiz .
Parelle Dasturini Yaratish Uchun Qadamlar
1.