TAILIEUCHUNG - Parallel Programming: for Multicore and Cluster Systems- P36

Parallel Programming: for Multicore and Cluster Systems- P36: Innovations in hardware architecture, like hyper-threading or multicore processors, mean that parallel computing resources are available for inexpensive desktop computers. In only a few years, many standard software products will be based on concepts of parallel programming implemented on such hardware, and the range of applications will be much broader than that of scientific computing, up to now the main application area for parallel computing | 342 6 Thread Programming causes all variables referenced in the construct to be shared except the private variables which are specified explicitly. The clause default none requires each variable in the construct to be specified explicitly as shared or private. The following example shows a first OpenMP program with a parallel region in which multiple threads perform an SPMD computation on shared and private data. Example The program code in Fig. uses a parallel construct for a parallel SPMD execution on an array x. The input values are read in the function initialized by the master thread. Within the parallel region the variables x and npoints are specified as shared and the variables iam np and mypoints are specified as private. All threads of the team of threads executing the parallel region store the number of threads in the variable np and their own thread id in the variable iam. The private variable mypoints is set to the number of points assigned to a thread. The function comput subdomainf is executed by each thread of the team using its own private variables iam and mypoints. The actual computations are performed on the shared array x. include include int npoints iam np mypoints double x int mainO scan 7 d fenpoints x double malloc npoints sizeof double initialize pragma omp parallel shared x npoints privatedam np mypoints np omp_get_num_threads iam omp_get_thread_num mypoints npoints np compute_subdomain x iam mypoints Fig. OpenMP program with parallel construct A nesting of parallel regions by calling a parallel construct within a parallel region is possible. However the default execution mode assigns only one thread to the team of the inner parallel region. The library function void int nested OpenMP 343 with a parameter nested 0 can be used to change the default execution mode to more than one thread for the inner region. The actual number of threads assigned to the inner region depends on the specific OpenMP .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.