Cov txheej txheem:

Omp_num_threads yog dab tsi?
Omp_num_threads yog dab tsi?

Video: Omp_num_threads yog dab tsi?

Video: Omp_num_threads yog dab tsi?
Video: Theta Overview 2024, Hlis ntuj nqeg
Anonim

OMP_NUM_THREADS . Cov OMP_NUM_THREADS ib puag ncig hloov pauv tau qhia cov xov tooj ntawm cov xov siv rau cov cheeb tsam sib npaug. Yog koj tsis teem OMP_NUM_THREADS , tus naj npawb ntawm cov processors muaj yog lub neej ntawd tus nqi los tsim ib pab neeg tshiab rau thawj zaug ntsib kev tsim vaj huam sib luag.

Yog li ntawd, Pragma OMP parallel yog dab tsi?

Cov pragma omp parallel yog siv rau fork ntxiv threads mus ua hauj lwm nyob rau hauv lub constructing thaum uas tig mus . Thawj cov xov yuav raug suav hais tias yog xov xov nrog xov ID 0. Piv txwv (C program): Zaub "Nyob zoo, ntiaj teb." siv ntau threads.

Ib tug kuj yuav nug, Kuv yuav hloov cov xov tooj hauv OpenMP li cas? Rau hloov tus lej ntawm OpenMP xov , hauv lub plhaub hais kom ua uas qhov kev zov me nyuam yuav khiav, sau: teeb OMP_NUM_THREADS = < xov tooj siv tau>. Qee lub plhaub xav tau qhov sib txawv thiab nws cov nqi xa tawm: export OMP_NUM_THREADS = < xov tooj siv tau>.

Tib neeg kuj nug, Kuv yuav suav cov xov tooj hauv OpenMP li cas?

OpenMP - tau txais (ntau tshaj) cov xov

  1. Txhawm rau txiav txim siab tias cov cai tau muab tso ua ke hauv OpenMP, kos rau _OPENMP #define.
  2. Kev hu mus nrhiav cov xov tooj ntau tshaj plaws uas muaj los ua haujlwm yog omp_get_max_threads() (los ntawm omp.

Kuv yuav ua li cas khiav ib qho kev pab cuam OMP hauv davhlau ya nyob twg?

Teeb tsa OpenMP ntawm Ubuntu / Linux

  1. Khiav sudo apt-tau nruab libomp-dev hauv koj lub Terminal.
  2. Tsim ib qhov C ++ Project, thiab npe nws HelloOpenMP.
  3. Xaiv koj qhov project, thiab mus rau Properties dialog.
  4. Mus rau C / C ++ Tsim -> Chaw.
  5. Xaiv GCC C ++ Compiler / Lwm yam.
  6. Hauv lwm tus chij input, ntxiv rau -fopenmp.

Pom zoo: