Changes between Version 29 and Version 30 of Next-GenOpenMPTransformation
- Timestamp:
- 06/25/19 16:56:33 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Next-GenOpenMPTransformation
v29 v30 391 391 === Translating `parallel` === 392 392 393 `parallel`: this spawns some nondeterministic number of threads . We will assume there is a constant `THREAD_MAX` defined somewhere. The number of threads created will be between 1 and `THREAD_MAX` (inclusive). Each thread is assigned an ID. The original ("master") thread has ID 0. All threads execute the parallel region.393 `parallel`: this spawns some nondeterministic number of threads, unless a `num_threads` clause is present, in which case the number of threads is specified exactly.. We will assume there is a constant `THREAD_MAX` defined somewhere. The number of threads created will be between 1 and `THREAD_MAX` (inclusive). Each thread is assigned an ID. The original ("master") thread has ID 0. All threads execute the parallel region. 394 394 395 395 {{{ … … 413 413 int _nthreads = 1+$choose_int(THREAD_MAX); 414 414 $omp_gteam gteam = $omp_gteam_create($here, nthreads); 415 $omp_gshared x_gshared = $omp_gshared_create(gteam, &x);416 415 417 416 $parfor (int _tid : {0..nthreads-1}) { 418 417 $omp_team team = $omp_team_create($here, gteam, _tid); 419 $omp_shared x_shared = $omp_shared_create(team, x_gshared);420 418 int _y; // private variable 421 419 422 420 ... 423 { // "x=5.2": 424 float tmp = 5.2; 425 426 $omp_write(x_shared, x_shared->local, &tmp); 427 } 421 x = 5.2; 428 422 _y = 3; 429 423 ... 430 424 $omp_barrier_and_flush(team); // implicit at end of parallel region 431 $omp_shared_destroy(x_shared);432 425 $omp_team_destroy(team); 433 426 } // end $parfor 434 $omp_gshared_destroy(x_gshared);435 427 $omp_gteam_destroy(gteam); 436 428 } // end parallel construct … … 502 494 => 503 495 504 The following translation assumes that $omp_shared has already been created somewhere.505 496 506 497 {{{
