Skip to content
Snippets Groups Projects
Verified Commit d52849cb authored by Dorian Stoll's avatar Dorian Stoll
Browse files

zellularautomat: c: Drop custom time measurement

parent 1cc3748a
No related branches found
No related tags found
No related merge requests found
...@@ -61,9 +61,9 @@ static char* ca_buffer_to_hex_str(const uint8_t* buf, size_t buf_size) ...@@ -61,9 +61,9 @@ static char* ca_buffer_to_hex_str(const uint8_t* buf, size_t buf_size)
return retval; return retval;
} }
static void ca_print_hash_and_time(const char *hash, const double time) static void ca_print_hash(const char *hash)
{ {
printf("hash: %s\ttime: %.3f s\n", (hash ? hash : "ERROR"), time); printf("hash: %s\n", (hash ? hash : "ERROR"));
} }
static void ca_clean_ghost_zones(line_t *buf, int lines) static void ca_clean_ghost_zones(line_t *buf, int lines)
...@@ -74,7 +74,7 @@ static void ca_clean_ghost_zones(line_t *buf, int lines) ...@@ -74,7 +74,7 @@ static void ca_clean_ghost_zones(line_t *buf, int lines)
} }
} }
void ca_hash_and_report(line_t *buf, int lines, double time_in_s) void ca_hash_and_report(line_t *buf, int lines)
{ {
uint8_t hash[MD5_DIGEST_LENGTH]; uint8_t hash[MD5_DIGEST_LENGTH];
uint32_t md_len; uint32_t md_len;
...@@ -87,7 +87,7 @@ void ca_hash_and_report(line_t *buf, int lines, double time_in_s) ...@@ -87,7 +87,7 @@ void ca_hash_and_report(line_t *buf, int lines, double time_in_s)
EVP_DigestFinal_ex(ctx, hash, &md_len); EVP_DigestFinal_ex(ctx, hash, &md_len);
char* hash_str = ca_buffer_to_hex_str(hash, MD5_DIGEST_LENGTH); char* hash_str = ca_buffer_to_hex_str(hash, MD5_DIGEST_LENGTH);
ca_print_hash_and_time(hash_str, time_in_s); ca_print_hash(hash_str);
free(hash_str); free(hash_str);
EVP_MD_CTX_free(ctx); EVP_MD_CTX_free(ctx);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <time.h>
/* a: pointer to array; x,y: coordinates; result: n-th element of anneal, /* a: pointer to array; x,y: coordinates; result: n-th element of anneal,
where n is the number of neighbors */ where n is the number of neighbors */
...@@ -12,14 +11,6 @@ ...@@ -12,14 +11,6 @@
(a)[(y)-1][(x) ] + (a)[(y)][(x) ] + (a)[(y)+1][(x) ] +\ (a)[(y)-1][(x) ] + (a)[(y)][(x) ] + (a)[(y)+1][(x) ] +\
(a)[(y)-1][(x)+1] + (a)[(y)][(x)+1] + (a)[(y)+1][(x)+1]]) (a)[(y)-1][(x)+1] + (a)[(y)][(x)+1] + (a)[(y)+1][(x)+1]])
#define TIME_GET(timer) \
struct timespec timer; \
clock_gettime(CLOCK_MONOTONIC, &timer)
#define TIME_DIFF(timer1, timer2) \
((timer2.tv_sec * 1.0E+9 + timer2.tv_nsec) - \
(timer1.tv_sec * 1.0E+9 + timer1.tv_nsec)) / 1.0E+9
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -35,7 +26,7 @@ typedef cell_state_t line_t[XSIZE + 2]; ...@@ -35,7 +26,7 @@ typedef cell_state_t line_t[XSIZE + 2];
void ca_init(int argc, char** argv, int *lines, int *its); void ca_init(int argc, char** argv, int *lines, int *its);
void ca_init_config(line_t *buf, int lines, int skip_lines); void ca_init_config(line_t *buf, int lines, int skip_lines);
void ca_hash_and_report(line_t *buf, int lines, double time_in_s); void ca_hash_and_report(line_t *buf, int lines);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -33,7 +33,7 @@ static void boundary(line_t *buf, int lines) ...@@ -33,7 +33,7 @@ static void boundary(line_t *buf, int lines)
for (int y = 0; y <= lines + 1; y++) { for (int y = 0; y <= lines + 1; y++) {
/* copy rightmost column to the buffer column 0 */ /* copy rightmost column to the buffer column 0 */
buf[y][0] = buf[y][XSIZE]; buf[y][0] = buf[y][XSIZE];
/* copy leftmost column to the buffer column XSIZE + 1 */ /* copy leftmost column to the buffer column XSIZE + 1 */
buf[y][XSIZE + 1] = buf[y][1]; buf[y][XSIZE + 1] = buf[y][1];
} }
...@@ -43,7 +43,7 @@ static void boundary(line_t *buf, int lines) ...@@ -43,7 +43,7 @@ static void boundary(line_t *buf, int lines)
for (int x = 0; x <= XSIZE + 1; x++) { for (int x = 0; x <= XSIZE + 1; x++) {
/* copy bottommost row to buffer row 0 */ /* copy bottommost row to buffer row 0 */
buf[0][x] = buf[lines][x]; buf[0][x] = buf[lines][x];
/* copy topmost row to buffer row lines + 1 */ /* copy topmost row to buffer row lines + 1 */
buf[lines + 1][x] = buf[1][x]; buf[lines + 1][x] = buf[1][x];
} }
...@@ -77,7 +77,6 @@ int main(int argc, char** argv) ...@@ -77,7 +77,6 @@ int main(int argc, char** argv)
ca_init_config(from, lines, 0); ca_init_config(from, lines, 0);
TIME_GET(sim_start);
for (int i = 0; i < its; i++) { for (int i = 0; i < its; i++) {
boundary(from, lines); boundary(from, lines);
simulate(from, to, lines); simulate(from, to, lines);
...@@ -86,9 +85,8 @@ int main(int argc, char** argv) ...@@ -86,9 +85,8 @@ int main(int argc, char** argv)
from = to; from = to;
to = temp; to = temp;
} }
TIME_GET(sim_stop);
ca_hash_and_report(from + 1, lines, TIME_DIFF(sim_start, sim_stop)); ca_hash_and_report(from + 1, lines);
free(from); free(from);
free(to); free(to);
......
...@@ -8,7 +8,6 @@ sources = [ ...@@ -8,7 +8,6 @@ sources = [
dependencies = [ dependencies = [
dependency('openmp'), dependency('openmp'),
cc.find_library('crypto'), cc.find_library('crypto'),
cc.find_library('rt'),
] ]
options = [ options = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment