My program crashes after doing MPI_Bcast. Below is the code and the error.
int size_of_simple = 0;
long long* simple = malloc(50000 * sizeof(long long));
if (rank == 0) {
size_of_simple = sieve_of_Eratosthenes(50000, simple);
}
MPI_Barrier(MPI_COMM_WORLD);
long long n = 0;
while (1) {
if (rank == 0) {
printf("Select the number: ");
fflush(stdout);
if (scanf("%lld", &n)) {};
}
if (rank == 0) {
sequential_algorithm(n, simple, size_of_simple);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Bcast(simple, size_of_simple, MPI_LONG_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(&size_of_simple, 1, MPI_INT, 0, MPI_COMM_WORLD); //error
parallel_algorithm(n, simple, size_of_simple, rank, size);
}
I also found out that when the first parameter in the sieve_of_Eratosthenes() function is changed, the number of bytes received in the error decreases, what could be the problem?