Created
February 2, 2016 06:07
-
-
Save rainiera/2a5afe763c13168c5810 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mpi.h" | |
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
MPI_Init(&argc, &argv); | |
int rank; | |
int size; | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
MPI_Comm_size(MPI_COMM_WORLD, &size); | |
int slice = 45200/32; | |
// Let each processor search the space [1412*rank, 1412*(rank+1)] | |
int i = 0; | |
for (i = slice*rank; i < slice*(rank+1); i++) { | |
if (i != 0 && i != 1 && (2000000111 % i) == 0) { | |
printf("%d is a factor of 2,000,000,111.\n", i); | |
return 1; | |
} | |
} | |
MPI_Finalize(); | |
printf("Yes, 2,000,000,111 is prime.\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment