OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-CompactHash commits / 1262412

Converting to monotonic clock
12624127f5b162fe396d6b26861e457637d0e9ba
by Bob Robey <brobey@lanl.gov> · 2019-07-06T15:06:06.000Z

Changed files (3) +32 -41

neigh2d.c +19 -19
……@@ -456,7 +456,7 @@ void neighbors2d( uint mesh_size, int levmx, float threshold, int *options, int
456456 }
457457 }
458458
459 struct timeval timer;
459 struct timespec timer;
460460 double time;
461461 cpu_timer_start(&timer);
462462 switch(options[0]){
……@@ -870,7 +870,7 @@ struct neighbor2d *neighbors2d_kdtree( uint ncells, int mesh_size, double *x, do
870870 */
871871struct neighbor2d *neighbors2d_hashcpu( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
872872{
873 struct timeval tSection, tTotal;
873 struct timespec tSection, tTotal;
874874 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
875875 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
876876 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -959,7 +959,7 @@ struct neighbor2d *neighbors2d_hashcpu( uint ncells, int mesh_size, int levmx, i
959959 */
960960struct neighbor2d *neighbors2d_hashlibcpu( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
961961{
962 struct timeval tSection, tTotal;
962 struct timespec tSection, tTotal;
963963 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
964964 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
965965 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1044,7 +1044,7 @@ struct neighbor2d *neighbors2d_hashlibcpu( uint ncells, int mesh_size, int levmx
10441044 */
10451045struct neighbor2d *neighbors2d_hashcpu_opt_1(uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
10461046{
1047 struct timeval tSection, tTotal;
1047 struct timespec tSection, tTotal;
10481048 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
10491049 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
10501050 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1143,7 +1143,7 @@ struct neighbor2d *neighbors2d_hashcpu_opt_1(uint ncells, int mesh_size, int lev
11431143 */
11441144struct neighbor2d *neighbors2d_hashlibcpu_opt_1( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
11451145{
1146 struct timeval tSection, tTotal;
1146 struct timespec tSection, tTotal;
11471147 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
11481148 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
11491149 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1233,7 +1233,7 @@ struct neighbor2d *neighbors2d_hashlibcpu_opt_1( uint ncells, int mesh_size, int
12331233 */
12341234struct neighbor2d *neighbors2d_hashcpu_opt_2( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
12351235{
1236 struct timeval tSection, tTotal;
1236 struct timespec tSection, tTotal;
12371237 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
12381238 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
12391239 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1342,7 +1342,7 @@ struct neighbor2d *neighbors2d_hashcpu_opt_2( uint ncells, int mesh_size, int le
13421342 */
13431343struct neighbor2d *neighbors2d_hashlibcpu_opt_2( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
13441344{
1345 struct timeval tSection, tTotal;
1345 struct timespec tSection, tTotal;
13461346 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
13471347 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
13481348 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1449,7 +1449,7 @@ struct neighbor2d *neighbors2d_hashlibcpu_opt_2( uint ncells, int mesh_size, int
14491449 */
14501450struct neighbor2d *neighbors2d_hashcpu_opt_3(uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
14511451{
1452 struct timeval tSection, tTotal;
1452 struct timespec tSection, tTotal;
14531453 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
14541454 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
14551455 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1591,7 +1591,7 @@ struct neighbor2d *neighbors2d_hashcpu_opt_3(uint ncells, int mesh_size, int lev
15911591 */
15921592struct neighbor2d *neighbors2d_hashlibcpu_opt_3( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
15931593{
1594 struct timeval tSection, tTotal;
1594 struct timespec tSection, tTotal;
15951595 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
15961596 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
15971597 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1730,7 +1730,7 @@ struct neighbor2d *neighbors2d_hashlibcpu_opt_3( uint ncells, int mesh_size, int
17301730
17311731struct neighbor2d *neighbors2d_hasholdlibcpu_opt_3( uint ncells, int mesh_size, int levmx, int *i, int *j, int *level )
17321732{
1733 struct timeval tSection, tTotal;
1733 struct timespec tSection, tTotal;
17341734 double setupCPUTime, createCPUTime, emptyCPUTime, writeCPUTime, readCPUTime, cleanupCPUTime, totalCPUTime;
17351735 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
17361736 if(DETAILED_TIMING) cpu_timer_start(&tSection);
……@@ -1864,7 +1864,7 @@ struct neighbor2d *neighbors2d_hasholdlibcpu_opt_3( uint ncells, int mesh_size,
18641864cl_mem neighbors2d_hashgpu( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
18651865 cl_mem level_buffer, cl_mem levtable_buffer)
18661866{
1867 struct timeval tSection, tTotal;
1867 struct timespec tSection, tTotal;
18681868 double setupCPUTime, createGPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
18691869 long startGPUTime, endGPUTime, GPUTime;
18701870 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -1984,7 +1984,7 @@ cl_mem neighbors2d_hashgpu( uint ncells, int mesh_size, int levmx, cl_mem i_buff
19841984cl_mem neighbors2d_hashlibgpu( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
19851985 cl_mem level_buffer, cl_mem levtable_buffer)
19861986{
1987 struct timeval tSection, tTotal;
1987 struct timespec tSection, tTotal;
19881988 double setupCPUTime, createCPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
19891989 long startGPUTime, endGPUTime, GPUTime;
19901990 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2106,7 +2106,7 @@ cl_mem neighbors2d_hashlibgpu( uint ncells, int mesh_size, int levmx, cl_mem i_b
21062106cl_mem neighbors2d_hashgpu_opt_1( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
21072107 cl_mem level_buffer, cl_mem levtable_buffer)
21082108{
2109 struct timeval tSection, tTotal;
2109 struct timespec tSection, tTotal;
21102110 double setupCPUTime, createGPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
21112111 long startGPUTime, endGPUTime, GPUTime;
21122112 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2228,7 +2228,7 @@ cl_mem neighbors2d_hashgpu_opt_1( uint ncells, int mesh_size, int levmx, cl_mem
22282228cl_mem neighbors2d_hashlibgpu_opt_1( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
22292229 cl_mem level_buffer, cl_mem levtable_buffer)
22302230{
2231 struct timeval tSection, tTotal;
2231 struct timespec tSection, tTotal;
22322232 double setupCPUTime, createCPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
22332233 long startGPUTime, endGPUTime, GPUTime;
22342234 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2351,7 +2351,7 @@ cl_mem neighbors2d_hashlibgpu_opt_1( uint ncells, int mesh_size, int levmx, cl_m
23512351cl_mem neighbors2d_hashgpu_opt_2( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
23522352 cl_mem level_buffer, cl_mem levtable_buffer)
23532353{
2354 struct timeval tSection, tTotal;
2354 struct timespec tSection, tTotal;
23552355 double setupCPUTime, createGPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
23562356 long startGPUTime, endGPUTime, GPUTime;
23572357 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2474,7 +2474,7 @@ cl_mem neighbors2d_hashgpu_opt_2( uint ncells, int mesh_size, int levmx, cl_mem
24742474cl_mem neighbors2d_hashlibgpu_opt_2( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
24752475 cl_mem level_buffer, cl_mem levtable_buffer)
24762476{
2477 struct timeval tSection, tTotal;
2477 struct timespec tSection, tTotal;
24782478 double setupCPUTime, createCPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
24792479 long startGPUTime, endGPUTime, GPUTime;
24802480 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2597,7 +2597,7 @@ cl_mem neighbors2d_hashlibgpu_opt_2( uint ncells, int mesh_size, int levmx, cl_m
25972597cl_mem neighbors2d_hashgpu_opt_3( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
25982598 cl_mem level_buffer, cl_mem levtable_buffer)
25992599{
2600 struct timeval tSection, tTotal;
2600 struct timespec tSection, tTotal;
26012601 double setupCPUTime, createGPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
26022602 long startGPUTime, endGPUTime, GPUTime;
26032603 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2719,7 +2719,7 @@ cl_mem neighbors2d_hashgpu_opt_3( uint ncells, int mesh_size, int levmx, cl_mem
27192719cl_mem neighbors2d_hashlibgpu_opt_3( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
27202720 cl_mem level_buffer, cl_mem levtable_buffer)
27212721{
2722 struct timeval tSection, tTotal;
2722 struct timespec tSection, tTotal;
27232723 double setupCPUTime, createCPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
27242724 long startGPUTime, endGPUTime, GPUTime;
27252725 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
……@@ -2847,7 +2847,7 @@ cl_mem neighbors2d_hashlibgpu_opt_3( uint ncells, int mesh_size, int levmx, cl_m
28472847cl_mem neighbors2d_hasholdlibgpu_opt_3( uint ncells, int mesh_size, int levmx, cl_mem i_buffer, cl_mem j_buffer,
28482848 cl_mem level_buffer, cl_mem levtable_buffer)
28492849{
2850 struct timeval tSection, tTotal;
2850 struct timespec tSection, tTotal;
28512851 double setupCPUTime, createGPUTime, emptyCPUTime, writeGPUTime, readGPUTime, cleanupCPUTime, totalCPUTime;
28522852 long startGPUTime, endGPUTime, GPUTime;
28532853 if(DETAILED_TIMING) cpu_timer_start(&tTotal);
timer/timer.c +11 -20
……@@ -53,31 +53,22 @@
5353 * Dennis Trujillo dptrujillo@lanl.gov, dptru10@gmail.com
5454 *
5555 */
56#include <sys/time.h>
57#include <stdlib.h>
58#include <stdio.h>
59#include <sys/types.h>
60#include <unistd.h>
61#include <string.h>
62
63//#ifdef HAVE_CONFIG_H
64//#include "config.h"
65//#endif
6656
57#include <sys/time.h>
6758#include "timer.h"
6859
69void cpu_timer_start(struct timeval *tstart_cpu){
70 gettimeofday(tstart_cpu, NULL);
60void cpu_timer_start(struct timespec *tstart_cpu)
61{
62 clock_gettime(CLOCK_MONOTONIC, tstart_cpu);
7163}
72
73double cpu_timer_stop(struct timeval tstart_cpu){
74 double result;
75 struct timeval tstop_cpu, tresult;
76
77 gettimeofday(&tstop_cpu, NULL);
64double cpu_timer_stop(struct timespec tstart_cpu)
65{
66 struct timespec tstop_cpu, tresult;
67 clock_gettime(CLOCK_MONOTONIC, &tstop_cpu);
7868 tresult.tv_sec = tstop_cpu.tv_sec - tstart_cpu.tv_sec;
79 tresult.tv_usec = tstop_cpu.tv_usec - tstart_cpu.tv_usec;
80 result = (double)tresult.tv_sec + (double)tresult.tv_usec*1.0e-6;
69 tresult.tv_nsec = tstop_cpu.tv_nsec - tstart_cpu.tv_nsec;
70 double result = (double)tresult.tv_sec + (double)tresult.tv_nsec*1.0e-9;
71
8172 return(result);
8273}
8374
timer/timer.h +2 -2
……@@ -61,8 +61,8 @@ extern "C"
6161{
6262#endif
6363
64void cpu_timer_start(struct timeval *tstart_cpu);
65double cpu_timer_stop(struct timeval tstart_cpu);
64void cpu_timer_start(struct timespec *tstart_cpu);
65double cpu_timer_stop(struct timespec tstart_cpu);
6666
6767#ifdef __cplusplus
6868}