華東狮免天學数学科学学院 School of Mathematical Sciences.East China Normal University OpenMP并行编程 (三) 运行库函数 环境变量 1 http://math.ecnu.edu.cn/~jypan
http://math.ecnu.edu.cn/~jypan 1 OpenMP 并行编程 (三) —— 运行库函数 —— 环境变量
华东师范大学数学科学学院 目录页 School of Mathematical Sciences,ECNU Contents 运行库函数 2 环境变量 3 编程示例 http://math.ecnu.edu.cn/~jypan
http://math.ecnu.edu.cn/~jypan 目录页 Contents 华东师范大学 数学科学学院 School of Mathematical Sciences, ECNU http://math.ecnu.edu.cn/~jypan 1 2 运行库函数 环境变量 3 编程示例
华东师范大学数学科学学院 目录页 School of Mathematical Sciences,ECNU Contents 运行库函数 Runtime Library Routines 运行环境函数 1 运行库函数 锁函数 ■ 时间函数 2 环境变量 3 编程示例 http://math.ecnu.edu.cn/-jypan
http://math.ecnu.edu.cn/~jypan 目录页 Contents 华东师范大学 数学科学学院 School of Mathematical Sciences, ECNU http://math.ecnu.edu.cn/~jypan 运行环境函数 锁函数 时间函数 1 2 运行库函数 环境变量 1 运行库函数 Runtime Library Routines 3 编程示例
运行环境函数 Execution Environment Routines omp_set_num_threads(int) 设置并行域中的线程个数(用在串行域中) omp_get_num_threads() 返回当前并行域中的线程个数 omp_get_max_threads() 返回并行域中缺省可用的最大线程个数 omp_get_thread_num() 返回当前线程的线程号,0号为主线程 omp_get_num_procs() 返回系统中处理器的个数 omp_in_parallel() 判断是否在并行域中 启用或关闭线程数目动态改变功能 omp_set_dynamic(int) (用在串行域中) omp_get_dynamic() 判断系统是否支持动态改变线程数目 omp_set_nested(int) 启用或关闭并行域嵌套功能(缺省为关闭) omp_get_nested() 判断系统是否支持并行域的嵌套 http://math.ecnu.edu.cn/-jypan 4
http://math.ecnu.edu.cn/~jypan 4 运行环境函数 Execution Environment Routines omp_set_num_threads(int) 设置并行域中的线程个数(用在串行域中) omp_get_num_threads() 返回当前并行域中的线程个数 omp_get_max_threads() 返回并行域中缺省可用的最大线程个数 omp_get_thread_num() 返回当前线程的线程号,0号为主线程 omp_get_num_procs() 返回系统中处理器的个数 omp_in_parallel() 判断是否在并行域中 omp_set_dynamic(int) 启用或关闭线程数目动态改变功能 (用在串行域中) omp_get_dynamic() 判断系统是否支持动态改变线程数目 omp_set_nested(int) 启用或关闭并行域嵌套功能(缺省为关闭) omp_get_nested() 判断系统是否支持并行域的嵌套
运行环境函数 ●omp_set_num_threads subroutine omp_set_num_threads(num threads) Fortran integer num threads C/C++ void omp_set_num_threads(int num_threads); ●omp_get_num_threads Fortran integer function omp_get_num_threads() C/C++ int omp_get_num_threads(void); omp_get_max_threads Fortran integer function omp_get_max_threads( C/C++ int omp_get_max_threads(void); http://math.ecnu.edu.cn/-jypan 5
http://math.ecnu.edu.cn/~jypan 5 运行环境函数 Fortran subroutine omp_set_num_threads(num_threads) integer num_threads C/C++ void omp_set_num_threads(int num_threads); omp_set_num_threads Fortran integer function omp_get_num_threads() C/C++ int omp_get_num_threads(void); omp_get_num_threads Fortran integer function omp_get_max_threads() C/C++ int omp_get_max_threads(void); omp_get_max_threads