SST EndStep SegFault
Created by: AaronV77
Hey Everyone,
I ran into an issue/bug/lack of understanding for ADIOS2. In the first example that I have provided the system crashes on the end_step, but in the second example, it does not. The difference between the two examples is that the first one open and closes ADIOS2 completely within the for loop on the reading side. Overall, the examples are just supposed to send and receive two messages and print here-1 & here-2 (twice per example). I double-checked the parameters to make sure that I have everything correct, I do need the adios2_data_sync, and the reading mode is being used.
How I am running the two examples is just with one proc apiece. These examples are just consolidated problems that I have ran into and have remnants of how I am applying them to our application.
How I expect the examples to operate is to print here-1 and here-2 twice either way. I should not have to open and close ADISO2 for each message that I want to receive.
Here is a makefile!
all:
gcc -c av_adios2.c
mpicc reader.c -o r av_adios2.o -ladios2
mpicc writer.c -o w av_adios2.o -ladios2
clean:
rm r w av_adios2.o
Example 1: reader-1.c
#include <adios2_c.h>
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char **argv)
{
size_t start[2] = {0,0};
size_t shape[2];
size_t count[2];
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size == 1) {
int * master_transfer_array = NULL;
adios2_step_status status;
adios2_adios * adios = adios2_init(MPI_COMM_SELF, adios2_debug_mode_on);
adios2_io * io = adios2_declare_io(adios, "sst_reader");
adios2_set_engine(io, "sst");
adios2_engine * reader_engine = adios2_open(io, "sst_example", adios2_mode_read);
for (int i = 0; i < 2; i++) {
adios2_begin_step(reader_engine, adios2_step_mode_read, -1.f, &status);
adios2_variable * adios2_var = adios2_inquire_variable(io, "my_array");
if (adios2_var) {
adios2_variable_shape(shape, adios2_var);
master_transfer_array = calloc((shape[0] * shape[1]), sizeof(int));
adios2_set_selection(adios2_var, 2, start, shape);
adios2_get(reader_engine, adios2_var, master_transfer_array, adios2_mode_sync);
free(master_transfer_array);
} else {
printf("\tERROR: Could not find the variable you were looking for.\n");
}
printf("Here-1..\n");
adios2_end_step(reader_engine);
printf("Here-2..\n");
}
adios2_close(reader_engine);
adios2_finalize(adios);
}
MPI_Finalize();
writer-1.c
#include <adios2_c.h>
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
size_t start[2] = {0,0};
size_t shape[2] = {1,8};
size_t count[2] = {1,8};
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size == 1) {
size_t nelements = count[0] * count[1];
int * my_array = calloc(nelements, sizeof(int));
for (int j = 0; j < nelements; ++j)
my_array[j] = j;
for (int j = 0; j < 2; ++j) {
adios2_step_status status;
adios2_adios * adios = adios2_init(MPI_COMM_SELF, adios2_debug_mode_on);
adios2_io *io = adios2_declare_io(adios, "sst_writer");
adios2_set_engine(io, "sst");
adios2_engine * writer_engine = adios2_open(io, "sst_example", adios2_mode_write);
adios2_variable *var_array = adios2_define_variable(io, "my_array", adios2_type_int32_t, 2, shape, start, count, adios2_constant_dims_true);
adios2_begin_step(writer_engine, adios2_step_mode_append, 0.0, &status);
adios2_put(writer_engine, var_array, my_array, adios2_mode_sync);
adios2_end_step(writer_engine);
adios2_close(writer_engine);
adios2_finalize(adios);
}
free(my_array);
}
MPI_Finalize();
return 0;
}
Example-1: reader-2.c
#include <adios2_c.h>
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char **argv)
{
size_t start[2] = {0,0};
size_t shape[2];
size_t count[2];
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size == 1) {
int * master_transfer_array = NULL;
for (int i = 0; i < 2; i++) {
adios2_step_status status;
adios2_adios * adios = adios2_init(MPI_COMM_SELF, adios2_debug_mode_on);
adios2_io * io = adios2_declare_io(adios, "sst_reader");
adios2_set_engine(io, "sst");
adios2_engine * reader_engine = adios2_open(io, "sst_example", adios2_mode_read);
adios2_begin_step(reader_engine, adios2_step_mode_read, -1.f, &status);
adios2_variable * adios2_var = adios2_inquire_variable(io, "my_array");
if (adios2_var) {
adios2_variable_shape(shape, adios2_var);
master_transfer_array = calloc((shape[0] * shape[1]), sizeof(int));
adios2_set_selection(adios2_var, 2, start, shape);
adios2_get(reader_engine, adios2_var, master_transfer_array, adios2_mode_sync);
free(master_transfer_array);
} else {
printf("\tERROR: Could not find the variable you were looking for.\n");
}
printf("Here-1..\n");
adios2_end_step(reader_engine);
adios2_close(reader_engine);
adios2_finalize(adios);
printf("Here-2..\n");
}
}
MPI_Finalize();
return 0;
}
writer-2.c
#include <adios2_c.h>
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
size_t start[2] = {0,0};
size_t shape[2] = {1,8};
size_t count[2] = {1,8};
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size == 1) {
size_t nelements = count[0] * count[1];
int * my_array = calloc(nelements, sizeof(int));
for (int j = 0; j < nelements; ++j)
my_array[j] = j;
for (int j = 0; j < 2; ++j) {
adios2_step_status status;
adios2_adios * adios = adios2_init(MPI_COMM_SELF, adios2_debug_mode_on);
adios2_io *io = adios2_declare_io(adios, "sst_writer");
adios2_set_engine(io, "sst");
adios2_engine * writer_engine = adios2_open(io, "sst_example", adios2_mode_write);
adios2_variable *var_array = adios2_define_variable(io, "my_array", adios2_type_int32_t, 2, shape, start, count, adios2_constant_dims_true);
adios2_begin_step(writer_engine, adios2_step_mode_append, 0.0, &status);
adios2_put(writer_engine, var_array, my_array, adios2_mode_sync);
adios2_end_step(writer_engine);
adios2_close(writer_engine);
adios2_finalize(adios);
}
free(my_array);
}
MPI_Finalize();
return 0;
}