openmp查看最大线程数量

  1. 云栖社区>
  2. 博客>
  3. 正文

openmp查看最大线程数量

lovedan 2017-07-27 15:44:00 浏览523
展开阅读全文

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(omp_test)

find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
    message("OpenMP found!")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

add_executable(omp_test omp_test.cpp)

omp_test.cpp

#include <iostream>
#include <string>
#include <omp.h>

using namespace std;

int main(){
    int numProcs = omp_get_num_procs();
    cout << "omp_get_num_procs() = " << numProcs << endl;
    return 0;
}

网友评论

登录后评论
0/500
评论
lovedan
+ 关注