OpenMP - 杂记

常用函数。

#include <iostream>
#include <omp.h>
#define NUM_THREADS 16
using namespace std;

int main(int argc, char* argv[]){
    omp_set_num_threads(NUM_THREADS);
    #pragma omp parallel
    {
        cout << "thread num: " << omp_get_num_threads() << endl;
        // omp_get_num_threads() 在并行区域之内调用,之外返回1
    }
    double time = omp_get_wtime();  // 用于获取当前的系统时间
    double tick = omp_get_wtick();  // 用于获取计时器的最小单位
    cout << "current time: " << time << endl;
    cout << "time tick: " << tick << endl;
    return 0;
}

待续。。。。。。

posted @ 2024-03-15 17:32  酥炸小黄瓜  阅读(29)  评论(0)    收藏  举报