예제 #1
0
int main(int argc, char** argv) {
  char const *deps[] = { "system" }; 
  hclib::launch(deps, 1, [&]() {
    myNew = new double[(SIZE + 2)];
    myVal = new double[(SIZE + 2)];
    initialOutput = new double[(SIZE + 2)];
    memset(myNew, 0, sizeof(double) * (SIZE + 2));
    memset(myVal, 0, sizeof(double) * (SIZE + 2));
    memset(initialOutput, 0, sizeof(double) * (SIZE + 2));
    initialOutput[SIZE + 1] = 1.0;
    myVal[SIZE + 1] = 1.0;
#ifdef VERIFY
    long start_seq = hclib_current_time_ms();
    runSequential();
    long end_seq = hclib_current_time_ms();
    double dur_seq = ((double)(end_seq-start_seq))/1000;
    printf("Sequential Time = %.3f\n",dur_seq);
#endif
    long start = hclib_current_time_ms();
    runParallel();
    long end = hclib_current_time_ms();
    double dur = ((double)(end-start))/1000;
#ifdef VERIFY
    validateOutput();
#endif
    printf("Time = %.3f\n",dur);
    delete(myNew);
    delete(myVal);
    delete(initialOutput);
  });
}
예제 #2
0
int main(int argc, char** argv) {
	// Initialize MPI
	MPI_Init(&argc, &argv);

	// Get MPI Rank and Size
	int mpi_rank;
	int mpi_size;
	MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
	MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);

	// Run sequential for testing purposes
	long long int num_throws = 0;
	if (mpi_rank == 0) {
		num_throws = get_input();
		runSequential(num_throws);
	}

	// Run MPI Parallel version
	runMPIParallel(num_throws, mpi_rank, mpi_size);

	return 0;
}