floyd.cc -> floyd-sequential.cc
git-svn-id: svn://anubis/gvsu@196 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
48ab8d89ed
commit
07c119d290
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
TARGETS := gen_adj_matrix
|
TARGETS := gen_adj_matrix
|
||||||
TARGETS += floyd
|
TARGETS += floyd-sequential
|
||||||
|
|
||||||
CXXFLAGS := -fopenmp
|
CXXFLAGS := -fopenmp
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sys/time.h> /* gettimeofday(), struct timeval */
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void usage(char * progname);
|
void usage(char * progname);
|
||||||
@ -36,6 +37,9 @@ int main(int argc, char * argv[])
|
|||||||
int D[2][num_verts][num_verts];
|
int D[2][num_verts][num_verts];
|
||||||
convertToMatrix(v, num_verts, (int *) &D[0]);
|
convertToMatrix(v, num_verts, (int *) &D[0]);
|
||||||
|
|
||||||
|
struct timeval before, after;
|
||||||
|
gettimeofday(&before, NULL); /* Start timing */
|
||||||
|
|
||||||
/* Run Floyd's Algorithm on D */
|
/* Run Floyd's Algorithm on D */
|
||||||
for (int k = 1; k <= num_verts; k++)
|
for (int k = 1; k <= num_verts; k++)
|
||||||
{
|
{
|
||||||
@ -58,6 +62,8 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gettimeofday(&after, NULL); /* Stop timing */
|
||||||
|
cout << "Result:" << endl;
|
||||||
/* Print out the final matrix */
|
/* Print out the final matrix */
|
||||||
for (int i = 0; i < num_verts; i++)
|
for (int i = 0; i < num_verts; i++)
|
||||||
{
|
{
|
||||||
@ -71,6 +77,11 @@ int main(int argc, char * argv[])
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
|
||||||
|
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
|
||||||
|
double diff = time_after - time_before;
|
||||||
|
cout << "Elapsed time: " << diff << " seconds." << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user