This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

allows for testing with and without mpi

parent 6ef792b4
#include <iostream>
#include <mpi.h>
#include <stdlib.h>
#include<time.h>
using namespace std;
......
#include "functions.hpp"
#include <chrono>
#include <mpi.h>
using namespace chrono;
int main(int argc, char* argv[])
......
#include "functions.hpp"
#include <chrono>
using namespace chrono;
int main(int argc, char* argv[])
{
srand(time(0));
int arr[ARR_SIZE];
for(int i = 0; i < ARR_SIZE; i++) {
arr[i] = (rand() % 10 + 1) * 10;
}
int size = sizeof(arr) / sizeof(arr[0]);
cout << "Starting execution." << endl;
auto start = high_resolution_clock::now();
int ierr = MPI_Init(&argc, &argv);
int procid, numprocs;
ierr = MPI_Comm_rank(MPI_COMM_WORLD, &procid);
ierr = MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
int result = MatrixChainOrder(arr, size);
ierr = MPI_Finalize();
cout << "Minimum number of multiplications is "
<< result
<< endl;
auto finish = high_resolution_clock::now();
auto duration = duration_cast<seconds>(finish - start);
//output time to console
auto minutes = duration.count() / 60;
auto seconds = duration.count() % 60;
cout << "Execution time: " << minutes << "m" << seconds << "s." << endl;
return 0;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment