코딩Coding/C++__C언어
C언어] ❤️OpenMP를 사용해서 내 컴퓨터의 가능한 Threads숫자 알아보기
내인생PLUS
2022. 6. 29. 00:17
728x90
https://www.geeksforgeeks.org/openmp-introduction-with-installation-guide/amp/
getthread_parallel.c
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int nthreads, tid;
#pragma omp parallel private(nthreads, tid)
{
tid = omp_get_thread_num();
printf("Welcome to GFG from thread = %d \n", tid);
if (tid == 0) {
nthreads = omp_get_num_threads();
printf("Number of threads = %d \n", nthreads);
}
}
}
gcc -o gfg -fopenmp getthread_parallel.c
ls
README.md getthread_parallel.c omp.cpp omp_helloworld.c
fibo.c gfg omp_fibo_parallel.cpp threads.cpp
./gfg
Welcome to GFG from thread = 2
Welcome to GFG from thread = 4
Welcome to GFG from thread = 1
Welcome to GFG from thread = 0
Number of threads = 8
Welcome to GFG from thread = 6
Welcome to GFG from thread = 5
Welcome to GFG from thread = 3
Welcome to GFG from thread = 7
다른 글 보기
Rust연습❤️
내 컴퓨터에 병렬 실행 가능한 코어수 알아보기
available_parallelism -
https://economiceco.tistory.com/m/14302
반응형