openmp查看最大線程數量


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;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM