3
This commit is contained in:
@@ -7,7 +7,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
double get_time()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
#define MAXTHREADS 16
|
||||
|
||||
@@ -32,6 +39,7 @@ int main(int argc, char **argv)
|
||||
nelems = (1LL << log_nelems);
|
||||
nelems_per_thread = nelems / nthreads;
|
||||
|
||||
double t_start = get_time();
|
||||
for ( i = 0; i < nthreads; i++)
|
||||
{
|
||||
myid[i] = i;
|
||||
@@ -50,12 +58,14 @@ int main(int argc, char **argv)
|
||||
|
||||
if (result == (nelems*(nelems-1))/2)
|
||||
{
|
||||
printf("Correct result: %ld\n",result);
|
||||
printf("Correct result: %llu\n",result);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Wrong result: %ld\n",result);
|
||||
printf("Wrong result: %llu\n",result);
|
||||
}
|
||||
double t_end = get_time();
|
||||
printf("Time taken: %f seconds\n", t_end - t_start);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user