共用方式為


A.3 使用平行區域

parallel指示詞 (2.3 節在頁面上 8) 可用於粗略粒狀資料單位的平行處理程式。 在下列範例中,每個執行緒在平行區域決定全域陣列的哪個部分x ,處理執行緒的數字為基礎:

#pragma omp parallel shared(x, npoints) private(iam, np, ipoints)
{
    iam = omp_get_thread_num();
    np =  omp_get_num_threads();
    ipoints = npoints / np;
    subdomain(x, iam, ipoints);
}