From 588fb675a05fee18ac27f64ca9d25bd84b20056f Mon Sep 17 00:00:00 2001 From: jaunatisblue Date: Sat, 28 Feb 2026 21:17:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=88=92=E5=88=864block?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E6=95=88=E6=9E=9C=E4=B8=8D=E5=A5=BD=EF=BC=8C?= =?UTF-8?q?=E8=BD=AC=E4=B8=BA=E7=A0=94=E7=A9=B6=E8=AE=BF=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMSS_NCKU_source/Parallel.C | 585 ++++++++---------------------------- AMSS_NCKU_source/Parallel.h | 4 +- AMSS_NCKU_source/cgh.C | 2 +- 3 files changed, 135 insertions(+), 456 deletions(-) diff --git a/AMSS_NCKU_source/Parallel.C b/AMSS_NCKU_source/Parallel.C index 79e92f1..a4c0c65 100644 --- a/AMSS_NCKU_source/Parallel.C +++ b/AMSS_NCKU_source/Parallel.C @@ -5,8 +5,6 @@ #include "misc.h" #include "parameters.h" #include -#include -#include int Parallel::partition1(int &nx, int split_size, int min_width, int cpusize, int shape) // special for 1 diemnsion { @@ -503,444 +501,6 @@ MyList *Parallel::distribute(MyList *PatchLIST, int cpusize, int i return BlL; } - - - - - -MyList *Parallel::distribute_new(MyList *PatchLIST, int cpusize, int ingfsi, int fngfsi, - bool periodic, int nodes) -{ -#ifdef USE_GPU_DIVIDE - double cpu_part, gpu_part; - map::iterator iter; - iter = parameters::dou_par.find("cpu part"); - if (iter != parameters::dou_par.end()) - { - cpu_part = iter->second; - } - else - { - int myrank; - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - // read parameter from file - const int LEN = 256; - char pline[LEN]; - string str, sgrp, skey, sval; - int sind; - char pname[50]; - { - map::iterator iter = parameters::str_par.find("inputpar"); - if (iter != parameters::str_par.end()) - { - strcpy(pname, (iter->second).c_str()); - } - else - { - cout << "Error inputpar" << endl; - exit(0); - } - } - ifstream inf(pname, ifstream::in); - if (!inf.good() && myrank == 0) - { - cout << "Can not open parameter file " << pname << endl; - MPI_Abort(MPI_COMM_WORLD, 1); - } - - for (int i = 1; inf.good(); i++) - { - inf.getline(pline, LEN); - str = pline; - - int status = misc::parse_parts(str, sgrp, skey, sval, sind); - if (status == -1) - { - cout << "error reading parameter file " << pname << " in line " << i << endl; - MPI_Abort(MPI_COMM_WORLD, 1); - } - else if (status == 0) - continue; - - if (sgrp == "ABE") - { - if (skey == "cpu part") - cpu_part = atof(sval.c_str()); - } - } - inf.close(); - - parameters::dou_par.insert(map::value_type("cpu part", cpu_part)); - } - iter = parameters::dou_par.find("gpu part"); - if (iter != parameters::dou_par.end()) - { - gpu_part = iter->second; - } - else - { - int myrank; - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - // read parameter from file - const int LEN = 256; - char pline[LEN]; - string str, sgrp, skey, sval; - int sind; - char pname[50]; - { - map::iterator iter = parameters::str_par.find("inputpar"); - if (iter != parameters::str_par.end()) - { - strcpy(pname, (iter->second).c_str()); - } - else - { - cout << "Error inputpar" << endl; - exit(0); - } - } - ifstream inf(pname, ifstream::in); - if (!inf.good() && myrank == 0) - { - cout << "Can not open parameter file " << pname << endl; - MPI_Abort(MPI_COMM_WORLD, 1); - } - - for (int i = 1; inf.good(); i++) - { - inf.getline(pline, LEN); - str = pline; - - int status = misc::parse_parts(str, sgrp, skey, sval, sind); - if (status == -1) - { - cout << "error reading parameter file " << pname << " in line " << i << endl; - MPI_Abort(MPI_COMM_WORLD, 1); - } - else if (status == 0) - continue; - - if (sgrp == "ABE") - { - if (skey == "gpu part") - gpu_part = atof(sval.c_str()); - } - } - inf.close(); - - parameters::dou_par.insert(map::value_type("gpu part", gpu_part)); - } - - if (nodes == 0) - nodes = cpusize / 2; -#else - if (nodes == 0) - nodes = cpusize; -#endif - - if (dim != 3) - { - cout << "distrivute: now we only support 3-dimension" << endl; - MPI_Abort(MPI_COMM_WORLD, 1); - } - - MyList *BlL = 0; - int split_size, min_size, block_size = 0; - - int min_width = 2 * Mymax(ghost_width, buffer_width); - int nxyz[dim], mmin_width[dim], min_shape[dim]; - - MyList *PLi = PatchLIST; - for (int i = 0; i < dim; i++) - min_shape[i] = PLi->data->shape[i]; - int lev = PLi->data->lev; - PLi = PLi->next; - while (PLi) - { - Patch *PP = PLi->data; - for (int i = 0; i < dim; i++) - min_shape[i] = Mymin(min_shape[i], PP->shape[i]); - if (lev != PLi->data->lev) - cout << "Parallel::distribute CAUSTION: meet Patches for different level: " << lev << " and " << PLi->data->lev << endl; - PLi = PLi->next; - } - - for (int i = 0; i < dim; i++) - mmin_width[i] = Mymin(min_width, min_shape[i]); - - min_size = mmin_width[0]; - for (int i = 1; i < dim; i++) - min_size = min_size * mmin_width[i]; - - PLi = PatchLIST; - while (PLi) - { - Patch *PP = PLi->data; - // PP->checkPatch(true); - int bs = PP->shape[0]; - for (int i = 1; i < dim; i++) - bs = bs * PP->shape[i]; - block_size = block_size + bs; - PLi = PLi->next; - } - split_size = Mymax(min_size, block_size / nodes); - split_size = Mymax(1, split_size); - - int n_rank = 0; - PLi = PatchLIST; - int reacpu = 0; - int current_block_id = 0; - while (PLi) { - Block *ng0, *ng; - bool first_block_in_patch = true; - Patch *PP = PLi->data; - reacpu += partition3(nxyz, split_size, mmin_width, nodes, PP->shape); - - for (int i = 0; i < nxyz[0]; i++) - for (int j = 0; j < nxyz[1]; j++) - for (int k = 0; k < nxyz[2]; k++) - { - // --- 1. 定义局部变量 --- - int ibbox_here[6], shape_here[3]; - double bbox_here[6], dd; - Block *current_ng_start = nullptr; // 本次循环产生的第一个(或唯一一个)块 - - ibbox_here[0] = (PP->shape[0] * i) / nxyz[0]; - ibbox_here[3] = (PP->shape[0] * (i + 1)) / nxyz[0] - 1; - ibbox_here[1] = (PP->shape[1] * j) / nxyz[1]; - ibbox_here[4] = (PP->shape[1] * (j + 1)) / nxyz[1] - 1; - ibbox_here[2] = (PP->shape[2] * k) / nxyz[2]; - ibbox_here[5] = (PP->shape[2] * (k + 1)) / nxyz[2] - 1; - - int core_blocks[] = {27, 28, 35, 36};//后续改为传入数组 - if (current_block_id == core_blocks[0] || current_block_id == core_blocks[1] || - current_block_id == core_blocks[2] || current_block_id == core_blocks[3]) - { - int aim_block[4]; - - switch (current_block_id) - { - case 27: - aim_block[0] = 24; - aim_block[1] = 25; - aim_block[2] = 26; - aim_block[3] = 27; - break; - case 28: - aim_block[0] = 28; - aim_block[1] = 29; - aim_block[2] = 30; - aim_block[3] = 23; - break; - case 35: - aim_block[0] = 40; - aim_block[1] = 33; - aim_block[2] = 34; - aim_block[3] = 35; - break; - case 36: - aim_block[0] = 36; - aim_block[1] = 37; - aim_block[2] = 38; - aim_block[3] = 39; - break; - - } - Block * split_first_block = nullptr; - Block * split_last_block = nullptr; - splitHotspotBlock(BlL, dim, ibbox_here[0], ibbox_here[3], ibbox_here[1], ibbox_here[4], ibbox_here[2], ibbox_here[5], - PP, aim_block[0], aim_block[1], aim_block[2],aim_block[3] ,ingfsi, fngfsi, periodic,split_first_block,split_last_block); - current_ng_start = split_first_block; - ng = split_last_block; - } - - else - { - // B. 普通块逻辑 (含 Ghost 扩张) - - - if (periodic) { - for(int d=0; d<3; d++) { - ibbox_here[d] -= ghost_width; - ibbox_here[d+3] += ghost_width; - } - } else { - ibbox_here[0] = Mymax(0, ibbox_here[0] - ghost_width); - ibbox_here[3] = Mymin(PP->shape[0] - 1, ibbox_here[3] + ghost_width); - ibbox_here[1] = Mymax(0, ibbox_here[1] - ghost_width); - ibbox_here[4] = Mymin(PP->shape[1] - 1, ibbox_here[4] + ghost_width); - ibbox_here[2] = Mymax(0, ibbox_here[2] - ghost_width); - ibbox_here[5] = Mymin(PP->shape[2] - 1, ibbox_here[5] + ghost_width); - } - - for(int d=0; d<3; d++) shape_here[d] = ibbox_here[d+3] - ibbox_here[d] + 1; - - // 物理坐标计算 (根据你的宏定义 Cell/Vertex) -#ifdef Vertex -#ifdef Cell -#error Both Cell and Vertex are defined -#endif - // 0--4, 5--10 - dd = (PP->bbox[3] - PP->bbox[0]) / (PP->shape[0] - 1); - bbox_here[0] = PP->bbox[0] + ibbox_here[0] * dd; - bbox_here[3] = PP->bbox[0] + ibbox_here[3] * dd; - - dd = (PP->bbox[4] - PP->bbox[1]) / (PP->shape[1] - 1); - bbox_here[1] = PP->bbox[1] + ibbox_here[1] * dd; - bbox_here[4] = PP->bbox[1] + ibbox_here[4] * dd; - - dd = (PP->bbox[5] - PP->bbox[2]) / (PP->shape[2] - 1); - bbox_here[2] = PP->bbox[2] + ibbox_here[2] * dd; - bbox_here[5] = PP->bbox[2] + ibbox_here[5] * dd; -#else -#ifdef Cell - // 0--5, 5--10 - dd = (PP->bbox[3] - PP->bbox[0]) / PP->shape[0]; - bbox_here[0] = PP->bbox[0] + (ibbox_here[0]) * dd; - bbox_here[3] = PP->bbox[0] + (ibbox_here[3] + 1) * dd; - - dd = (PP->bbox[4] - PP->bbox[1]) / PP->shape[1]; - bbox_here[1] = PP->bbox[1] + (ibbox_here[1]) * dd; - bbox_here[4] = PP->bbox[1] + (ibbox_here[4] + 1) * dd; - - dd = (PP->bbox[5] - PP->bbox[2]) / PP->shape[2]; - bbox_here[2] = PP->bbox[2] + (ibbox_here[2]) * dd; - bbox_here[5] = PP->bbox[2] + (ibbox_here[5] + 1) * dd; -#else -#error Not define Vertex nor Cell -#endif -#endif - //ng = createMappedBlock(BlL, dim, shape_here, bbox_here, current_block_id, ingfsi, fngfsi, PP->lev); - Block * ng = new Block(dim, shape_here, bbox_here, current_block_id, ingfsi, fngfsi, PP->lev); - if (BlL) - BlL->insert(ng); - else - BlL = new MyList(ng); - current_ng_start = ng; - } - - // --- 3. 统一处理 Patch 起始 Block 指针 --- - if (first_block_in_patch) { - ng0 = current_ng_start; - - // 立即设置 PP->blb,避免后续循环覆盖 ng0 - MyList *Bp_start = BlL; - while (Bp_start && Bp_start->data != ng0) Bp_start = Bp_start->next; - PP->blb = Bp_start; - - first_block_in_patch = false; - } - - current_block_id++; - } - - // --- 4. 设置 Patch 结束 Block 指针 --- - MyList *Bp_end = BlL; - while (Bp_end && Bp_end->data != ng) - Bp_end = Bp_end->next; - PP->ble = Bp_end; - - PLi = PLi->next; - first_block_in_patch = true; - } - if (reacpu < nodes * 2 / 3) - { - int myrank; - MPI_Comm_rank(MPI_COMM_WORLD, &myrank); - if (myrank == 0) - cout << "Parallel::distribute CAUSTION: level#" << lev << " uses essencially " << reacpu << " processors vs " << nodes << " nodes run, your scientific computation scale is not as large as you estimate." << endl; - } - - return BlL; -} - - -Block* Parallel::splitHotspotBlock(MyList* &BlL, int _dim, - int ib0_orig, int ib3_orig, - int jb1_orig, int jb4_orig, - int kb2_orig, int kb5_orig, - Patch* PP, int r_1, int r_2, int r_3, int r_4, - int ingfsi, int fngfsi, bool periodic, - Block* &split_first_block, Block* &split_last_block) -{ - // 1. 计算四分索引区间 - // 计算 X 方向的总网格数 - int total_len = ib3_orig - ib0_orig + 1; - // 计算三个切分点,确保覆盖 [ib0_orig, ib3_orig] - // 段 1: [ib0_orig, m1] - // 段 2: [m1 + 1, m2] - // 段 3: [m2 + 1, m3] - // 段 4: [m3 + 1, ib3_orig] - int m1 = ib0_orig + total_len / 4 - 1; - int m2 = ib0_orig + total_len / 2 - 1; - int m3 = ib0_orig + (3 * total_len) / 4 - 1; - - int indices[4][6] = { - {ib0_orig, jb1_orig, kb2_orig, m1, jb4_orig, kb5_orig}, // 子块 1 - {m1 + 1, jb1_orig, kb2_orig, m2, jb4_orig, kb5_orig}, // 子块 2 - {m2 + 1, jb1_orig, kb2_orig, m3, jb4_orig, kb5_orig}, // 子块 3 - {m3 + 1, jb1_orig, kb2_orig, ib3_orig, jb4_orig, kb5_orig} // 子块 4 - }; - - int target_ranks[4] = {r_1, r_2, r_3, r_4}; - - // 2. 内部处理逻辑 (保持原有的 Ghost 扩张和物理坐标转换) - auto createSubBlock = [&](int* ib_raw, int target_rank) { - int ib_final[6]; - int sh_here[3]; - double bb_here[6], dd; - - // --- 逻辑 A: Ghost 扩张 --- - if (periodic) { - ib_final[0] = ib_raw[0] - ghost_width; - ib_final[3] = ib_raw[3] + ghost_width; - ib_final[1] = ib_raw[1] - ghost_width; - ib_final[4] = ib_raw[4] + ghost_width; - ib_final[2] = ib_raw[2] - ghost_width; - ib_final[5] = ib_raw[5] + ghost_width; - } else { - ib_final[0] = Mymax(0, ib_raw[0] - ghost_width); - ib_final[3] = Mymin(PP->shape[0] - 1, ib_raw[3] + ghost_width); - ib_final[1] = Mymax(0, ib_raw[1] - ghost_width); - ib_final[4] = Mymin(PP->shape[1] - 1, ib_raw[4] + ghost_width); - ib_final[2] = Mymax(0, ib_raw[2] - ghost_width); - ib_final[5] = Mymin(PP->shape[2] - 1, ib_raw[5] + ghost_width); - } - - sh_here[0] = ib_final[3] - ib_final[0] + 1; - sh_here[1] = ib_final[4] - ib_final[1] + 1; - sh_here[2] = ib_final[5] - ib_final[2] + 1; - - // --- 逻辑 B: 物理坐标计算 --- - dd = (PP->bbox[3] - PP->bbox[0]) / PP->shape[0]; - bb_here[0] = PP->bbox[0] + ib_final[0] * dd; - bb_here[3] = PP->bbox[0] + (ib_final[3] + 1) * dd; - - dd = (PP->bbox[4] - PP->bbox[1]) / PP->shape[1]; - bb_here[1] = PP->bbox[1] + ib_final[1] * dd; - bb_here[4] = PP->bbox[1] + (ib_final[4] + 1) * dd; - - dd = (PP->bbox[5] - PP->bbox[2]) / PP->shape[2]; - bb_here[2] = PP->bbox[2] + ib_final[2] * dd; - bb_here[5] = PP->bbox[2] + (ib_final[5] + 1) * dd; - - Block* Bg = new Block(_dim, sh_here, bb_here, target_rank, ingfsi, fngfsi, PP->lev); - - if (BlL) BlL->insert(Bg); - else BlL = new MyList(Bg); - - return Bg; - }; - - // 3. 执行创建并返回首尾指针 - split_first_block = createSubBlock(indices[0], target_ranks[0]); - createSubBlock(indices[1], target_ranks[1]); // 中间块仅插入 List - createSubBlock(indices[2], target_ranks[2]); // 中间块仅插入 List - split_last_block = createSubBlock(indices[3], target_ranks[3]); - - return split_first_block; -} - MyList *Parallel::distribute_hard(MyList *PatchLIST, int cpusize, int ingfsi, int fngfsi, bool periodic, int nodes) { @@ -1150,17 +710,35 @@ MyList *Parallel::distribute_hard(MyList *PatchLIST, int cpusize, int kb2 = (PP->shape[2] * k) / nxyz[2]; int kb5 = (PP->shape[2] * (k + 1)) / nxyz[2] - 1; - int r_l, r_r; - if(current_block_id == 27) { r_l = 26; r_r = 27; } - else if(current_block_id == 28) { r_l = 28; r_r = 29; } - else if(current_block_id == 35) { r_l = 34; r_r = 35; } - else { r_l = 36; r_r = 37; } + int r_1, r_2, r_3, r_4; Block * split_first_block = nullptr; Block * split_last_block = nullptr; - // 拆分逻辑:该函数应更新类成员变量 split_first_block 和 split_last_block - splitHotspotBlock(BlL, dim, ib0, ib3, jb1, jb4, kb2, kb5, - PP, r_l, r_r, ingfsi, fngfsi, periodic,split_first_block,split_last_block); - + if(current_block_id == 27) + { + r_1 = 24; r_2 = 25; r_3 = 26; r_4 = 27; + splitHotspotBlock(BlL, dim, ib0, ib3, jb1, jb4, kb2, kb5, + PP, r_1,r_2,r_3, r_4, ingfsi, fngfsi, periodic,split_first_block,split_last_block); + } + + else if(current_block_id == 28) + { + r_1 = 28; r_2 = 29; + splitHotspotBlock(BlL, dim, ib0, ib3, jb1, jb4, kb2, kb5, + PP, r_1, r_2, ingfsi, fngfsi, periodic,split_first_block,split_last_block); + } + else if(current_block_id == 35) + { + r_1 = 34; r_2 = 35; + splitHotspotBlock(BlL, dim, ib0, ib3, jb1, jb4, kb2, kb5, + PP, r_1, r_2, ingfsi, fngfsi, periodic,split_first_block,split_last_block); + } + else + { + r_1 = 36; r_2 = 37; r_3 = 38; r_4 = 39; + splitHotspotBlock(BlL, dim, ib0, ib3, jb1, jb4, kb2, kb5, + PP, r_1,r_2,r_3, r_4, ingfsi, fngfsi, periodic,split_first_block,split_last_block); + } + current_ng_start = split_first_block; ng = split_last_block; } @@ -1263,10 +841,104 @@ MyList *Parallel::distribute_hard(MyList *PatchLIST, int cpusize, return BlL; } + + + /** + * @brief 将当前 Block 几何4等分并存入列表 + */ + + +Block* Parallel::splitHotspotBlock(MyList* &BlL, int _dim, + int ib0_orig, int ib3_orig, + int jb1_orig, int jb4_orig, + int kb2_orig, int kb5_orig, + Patch* PP, int r_1, int r_2, int r_3, int r_4, + int ingfsi, int fngfsi, bool periodic, + Block* &split_first_block, Block* &split_last_block) +{ + // 1. 计算四分索引区间 + // 计算 X 方向的总网格数 + int total_len = ib3_orig - ib0_orig + 1; + + // 计算三个切分点,确保覆盖 [ib0_orig, ib3_orig] + // 段 1: [ib0_orig, m1] + // 段 2: [m1 + 1, m2] + // 段 3: [m2 + 1, m3] + // 段 4: [m3 + 1, ib3_orig] + int m1 = ib0_orig + total_len / 4 - 1; + int m2 = ib0_orig + total_len / 2 - 1; + int m3 = ib0_orig + (3 * total_len) / 4 - 1; + + int indices[4][6] = { + {ib0_orig, jb1_orig, kb2_orig, m1, jb4_orig, kb5_orig}, // 子块 1 + {m1 + 1, jb1_orig, kb2_orig, m2, jb4_orig, kb5_orig}, // 子块 2 + {m2 + 1, jb1_orig, kb2_orig, m3, jb4_orig, kb5_orig}, // 子块 3 + {m3 + 1, jb1_orig, kb2_orig, ib3_orig, jb4_orig, kb5_orig} // 子块 4 + }; + + int target_ranks[4] = {r_1, r_2, r_3, r_4}; + + // 2. 内部处理逻辑 (保持原有的 Ghost 扩张和物理坐标转换) + auto createSubBlock = [&](int* ib_raw, int target_rank) { + int ib_final[6]; + int sh_here[3]; + double bb_here[6], dd; + + // --- 逻辑 A: Ghost 扩张 --- + if (periodic) { + ib_final[0] = ib_raw[0] - ghost_width; + ib_final[3] = ib_raw[3] + ghost_width; + ib_final[1] = ib_raw[1] - ghost_width; + ib_final[4] = ib_raw[4] + ghost_width; + ib_final[2] = ib_raw[2] - ghost_width; + ib_final[5] = ib_raw[5] + ghost_width; + } else { + ib_final[0] = Mymax(0, ib_raw[0] - ghost_width); + ib_final[3] = Mymin(PP->shape[0] - 1, ib_raw[3] + ghost_width); + ib_final[1] = Mymax(0, ib_raw[1] - ghost_width); + ib_final[4] = Mymin(PP->shape[1] - 1, ib_raw[4] + ghost_width); + ib_final[2] = Mymax(0, ib_raw[2] - ghost_width); + ib_final[5] = Mymin(PP->shape[2] - 1, ib_raw[5] + ghost_width); + } + + sh_here[0] = ib_final[3] - ib_final[0] + 1; + sh_here[1] = ib_final[4] - ib_final[1] + 1; + sh_here[2] = ib_final[5] - ib_final[2] + 1; + + // --- 逻辑 B: 物理坐标计算 --- + dd = (PP->bbox[3] - PP->bbox[0]) / PP->shape[0]; + bb_here[0] = PP->bbox[0] + ib_final[0] * dd; + bb_here[3] = PP->bbox[0] + (ib_final[3] + 1) * dd; + + dd = (PP->bbox[4] - PP->bbox[1]) / PP->shape[1]; + bb_here[1] = PP->bbox[1] + ib_final[1] * dd; + bb_here[4] = PP->bbox[1] + (ib_final[4] + 1) * dd; + + dd = (PP->bbox[5] - PP->bbox[2]) / PP->shape[2]; + bb_here[2] = PP->bbox[2] + ib_final[2] * dd; + bb_here[5] = PP->bbox[2] + (ib_final[5] + 1) * dd; + + Block* Bg = new Block(_dim, sh_here, bb_here, target_rank, ingfsi, fngfsi, PP->lev); + + if (BlL) BlL->insert(Bg); + else BlL = new MyList(Bg); + + return Bg; + }; + + // 3. 执行创建并返回首尾指针 + split_first_block = createSubBlock(indices[0], target_ranks[0]); + createSubBlock(indices[1], target_ranks[1]); // 中间块仅插入 List + createSubBlock(indices[2], target_ranks[2]); // 中间块仅插入 List + split_last_block = createSubBlock(indices[3], target_ranks[3]); +} + /** * @brief 将当前 Block 几何二等分并存入列表 * @param axis 拆分轴:0-x, 1-y, 2-z (建议选最长轴) */ + + Block* Parallel::splitHotspotBlock(MyList* &BlL, int _dim, int ib0_orig, int ib3_orig, int jb1_orig, int jb4_orig, @@ -1347,10 +1019,17 @@ Block* Parallel::splitHotspotBlock(MyList* &BlL, int _dim, { // 映射表逻辑 int target_rank = block_id; - if (block_id == 26) target_rank = 25; - else if (block_id == 29) target_rank = 30; - else if (block_id == 34) target_rank = 33; - else if (block_id == 37) target_rank = 38; + switch(block_id){ + case 24: target_rank = 23; break; + case 25: target_rank = 23; break; + case 26: target_rank = 23; break; + case 29: target_rank = 30; break; + case 34: target_rank = 33; break; + case 37: target_rank = 40; break; + case 38: target_rank = 40; break; + case 39: target_rank = 40; break; + + } Block* ng = new Block(dim, shape, bbox, target_rank, ingfsi, fngfsi, lev); diff --git a/AMSS_NCKU_source/Parallel.h b/AMSS_NCKU_source/Parallel.h index a1931d3..7c249e7 100644 --- a/AMSS_NCKU_source/Parallel.h +++ b/AMSS_NCKU_source/Parallel.h @@ -32,16 +32,16 @@ namespace Parallel int partition2(int *nxy, int split_size, int *min_width, int cpusize, int *shape); // special for 2 diemnsions int partition3(int *nxyz, int split_size, int *min_width, int cpusize, int *shape); MyList *distribute(MyList *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks - MyList *distribute_new(MyList *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks MyList *distribute_hard(MyList *PatchLIST, int cpusize, int ingfsi, int fngfs, bool periodic, int nodes = 0); // produce corresponding Blocks Block* splitHotspotBlock(MyList* &BlL, int _dim, int ib0_orig, int ib3_orig, int jb1_orig, int jb4_orig, int kb2_orig, int kb5_orig, - Patch* PP, int r_left, int r_right, + Patch* PP, int r_1, int r_2, int ingfsi, int fngfsi, bool periodic, Block* &split_first_block, Block* &split_last_block); + Block* splitHotspotBlock(MyList* &BlL, int _dim, int ib0_orig, int ib3_orig, int jb1_orig, int jb4_orig, diff --git a/AMSS_NCKU_source/cgh.C b/AMSS_NCKU_source/cgh.C index 59296f9..a72ba42 100644 --- a/AMSS_NCKU_source/cgh.C +++ b/AMSS_NCKU_source/cgh.C @@ -144,7 +144,7 @@ void cgh::compose_cgh(int nprocs) for (int lev = 0; lev < levels; lev++) { checkPatchList(PatL[lev], false); - Parallel::distribute_new(PatL[lev], nprocs, ingfs, fngfs, false); + Parallel::distribute_hard(PatL[lev], nprocs, ingfs, fngfs, false); #if (RPB == 1) // we need distributed box of PatL[lev] and PatL[lev-1] if (lev > 0)