Hi,
The NDEBUG define is not present in the libMesh headers even when I compile
libMesh 0.9.5 in optimized mode. My question is: should I provide -DNDEBUG
flag while compiling my code? I can reproduce the error as follows:
*Compiling petsc_vector_test.cpp with NDEBUG flag gives me expected
behavior:*
-bash-4.1$ ./petsc_vector_test
MPI_num_procs = 1, LibMesh_num_procs = 1, MPI_rank = 0, LibMesh_rank = 0, a
= 0.000000, b = 59.000000
*** Warning, AutoPtr is deprecated and will be removed in a future library
version! ./include/libmesh/auto_ptr.h, line 271, compiled Mar 9 2016 at
19:43:54 ***
-bash-4.1$ mpiexec -n 2 ./petsc_vector_test
MPI_num_procs = 2, LibMesh_num_procs = 2, MPI_rank = 0, LibMesh_rank = 0, a
= 31.000000, b = 30.000000
MPI_num_procs = 2, LibMesh_num_procs = 2, MPI_rank = 1, LibMesh_rank = 1, a
= 29.000000, b = 28.000000
*Compiling petsc_vector_test.cpp without NDEBUG flag leads to crash:*
-bash-4.1$ ./petsc_vector_test
Assertion `local_index < _local_size' failed.
local_index = 0
_local_size = 0
*petsc_vector_test.cpp:*
#include "mpi.h"
#include "libmesh.h"
#include "petsc_vector.h"
using namespace libMesh;
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
int mpi_rank, mpi_size;
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
LibMeshInit libmesh_init(argc, argv, MPI_COMM_WORLD);
int num_procs = libmesh_init.comm().size();
int rank = libmesh_init.comm().rank();
unsigned int N = 60;
unsigned int n = 60/num_procs;
std::vector<unsigned int> send_list(2);
if(num_procs != 1)
{
if(rank != 0)
send_list[0] = rank*n-1;
else
send_list[0] = n+1;
if(rank != num_procs - 1)
send_list[1] = (rank+1)*n;
else
send_list[1] = rank*n-2;
}
else
{
send_list[0] = 0;
send_list[1] = N-1;
}
PetscVector<double> parallel(libmesh_init.comm(), N, n, PARALLEL);
for(unsigned int i=0; i<n; i++)
parallel.set(rank*n+i, rank*n+i);
parallel.close();
PetscVector<double> ghosted(libmesh_init.comm(), N, n, send_list,
GHOSTED);;
parallel.localize(ghosted, send_list);
double a = ghosted(send_list[0]);
double b = ghosted(send_list[1]);
printf("MPI_num_procs = %d, LibMesh_num_procs = %d, MPI_rank = %d,
LibMesh_rank = %d, a = %f, b = %f\n", mpi_size, num_procs, mpi_rank, rank,
a, b);
return 0;
}
Thanks,
Harshad
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users