C언어] ❤️OpenMP를 사용해서 내 컴퓨터의 가능한 Threads숫자 알아보기
https://www.geeksforgeeks.org/openmp-introduction-with-installation-guide/amp/
OpenMP | Introduction with Installation Guide - GeeksforGeeks
After a long thirst for parallelizing highly regular loops in matrix-oriented numerical programming, OpenMP was introduced by OpenMP Architecture Review Board (ARB) on 1997. In the subsequent releases, the enthusiastic OpenMP team added many features to it
www.geeksforgeeks.org
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
Rust연습❤️내 컴퓨터에 병렬 실행 가능한 코어수 알아보기available_parallelism
Rust 내 컴퓨터에 병렬 실행 가능한 코어수 알아보기 fn main () { println!("You can use {:?} threads(available_parallelism) now. ", std::thread::available_parallelism().unwrap()); } 결과 Compiling play..
economiceco.tistory.com