Я пытаюсь написать код C++, вызывающий ScaLAPACK, и столкнулся с этой проблемой.
После извлечения проблемы до минимального примера я хочу передать общую матрицу, которая здесь — это особый случай, то есть 1x1, к сетке процесса, применяемый к каждой строке этой сетки.
Например, сетка состоит из 2 строк x 1 столбца, и процесс 1 хочет передать значение для обработки 0.
И вот пример из примерно 50 строк, показывающий этот странный результат:
// build with: (but version does not matter I think)
// mpicxx --std=c++17 test.cpp -L/opt/scalapack-2.2.0 -L/opt/LAPACK/3.10.0/ -L/opt/OpenBLAS/0.3.19/lib64 -lscalapack -llapack -lopenblas -lgfortran -o test.x
// run with:
// OMP_NUM_THREADS=1 LD_LIBRARY_PATH=/opt/LAPACK/3.10.0:/opt/OpenBLAS/0.3.19/lib64:/opt/MPICH/4.0.2/lib:$LD_LIBRARY_PATH mpirun -np 2 ./test.x
#include
#include
#include
#include
#include
#include
#include
#include "mpi.h"
#include
#include
#include
extern "C" {
void Cblacs_get(const int ictxt, const int what, int *val);
void Cblacs_pinfo(int *myrank, int *nprocs);
void Cblacs_gridinit(int *ictxt, const char *order, const int nprow, const int npcol);
void Cblacs_gridinfo(const int ictxt, int *nprow, int *npcol, int *myrow, int *mycol);
void Cblacs_gridexit(const int ictxt);
void descinit_(int *desc,
const int *m, const int *n, const int *mb, const int *nb, const int *irsrc, const int *icsrc, const int *ictxt, const int *lld, int *info);
void Cigebs2d(
const int ConTxt, const char *scope, const char *top,
const int m, const int n, const int *A, const int lda);
void Cigebr2d(
const int ConTxt, const char *scope, const char *top,
const int m, const int n, int *A, const int lda,
const int rsrc, const int csrc);
// compute LOCr or LOCc (local size of data for distributed array)
int numroc_(const int *n, const int *nb, const int *iproc, const int *isrcproc, const int *nprocs);
}
int main(int argc, char **argv) {
MPI_Init(&argc, &argv);
int myid, numprocs;
int ictxt, myrow, mycol;
int nprow = 2, npcol = 1;
int magic = 4;
Cblacs_pinfo(&myid, &numprocs);
Cblacs_get(0, 0, &ictxt);
Cblacs_gridinit(&ictxt, "Row", nprow, npcol);
Cblacs_gridinfo(ictxt, &nprow, &npcol, &myrow, &mycol);
std::this_thread::sleep_for(std::chrono::seconds(magic-myid));
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78296430/wrong-output-for-igebs2d-igebr2d-matrix-broadcast-in-scalapack[/url]
Я пытаюсь написать код C++, вызывающий ScaLAPACK, и столкнулся с этой проблемой. После извлечения проблемы до минимального примера я хочу передать общую матрицу, которая здесь — это особый случай, то есть 1x1, к сетке процесса, применяемый к каждой строке этой сетки. Например, сетка состоит из 2 строк x 1 столбца, и процесс 1 хочет передать значение для обработки 0. И вот пример из примерно 50 строк, показывающий этот странный результат: [code]// build with: (but version does not matter I think) // mpicxx --std=c++17 test.cpp -L/opt/scalapack-2.2.0 -L/opt/LAPACK/3.10.0/ -L/opt/OpenBLAS/0.3.19/lib64 -lscalapack -llapack -lopenblas -lgfortran -o test.x // run with: // OMP_NUM_THREADS=1 LD_LIBRARY_PATH=/opt/LAPACK/3.10.0:/opt/OpenBLAS/0.3.19/lib64:/opt/MPICH/4.0.2/lib:$LD_LIBRARY_PATH mpirun -np 2 ./test.x
void Cblacs_get(const int ictxt, const int what, int *val); void Cblacs_pinfo(int *myrank, int *nprocs); void Cblacs_gridinit(int *ictxt, const char *order, const int nprow, const int npcol); void Cblacs_gridinfo(const int ictxt, int *nprow, int *npcol, int *myrow, int *mycol); void Cblacs_gridexit(const int ictxt); void descinit_(int *desc, const int *m, const int *n, const int *mb, const int *nb, const int *irsrc, const int *icsrc, const int *ictxt, const int *lld, int *info);
void Cigebs2d( const int ConTxt, const char *scope, const char *top, const int m, const int n, const int *A, const int lda); void Cigebr2d( const int ConTxt, const char *scope, const char *top, const int m, const int n, int *A, const int lda, const int rsrc, const int csrc);
// compute LOCr or LOCc (local size of data for distributed array) int numroc_(const int *n, const int *nb, const int *iproc, const int *isrcproc, const int *nprocs);
}
int main(int argc, char **argv) { MPI_Init(&argc, &argv);
int myid, numprocs; int ictxt, myrow, mycol; int nprow = 2, npcol = 1; int magic = 4; Cblacs_pinfo(&myid, &numprocs); Cblacs_get(0, 0, &ictxt); Cblacs_gridinit(&ictxt, "Row", nprow, npcol); Cblacs_gridinfo(ictxt, &nprow, &npcol, &myrow, &mycol); std::this_thread::sleep_for(std::chrono::seconds(magic-myid)); std::cout
Я пытаюсь написать код на C++, вызывающий ScaLAPACK, и столкнулся с этой проблемой.
Я хочу переупорядочить столбцы для распределенной матрицы. Следуя объяснению вместе с исходным кодом в ScaLAPACK, я так и не могу понять, что не так с моими...
Я учусь использовать процедуру scalaPACK для метода наименьших квадратов, но не могу заставить ее работать.
Буду признателен за ваше понимание этого вопроса.
В коде ниже предполагается распределение матрицы A 8x8 на 4 локальные матрицы A_loc 4x4 и...