Skip to content
Snippets Groups Projects
Commit c38ab04b authored by Armando Luiz Nicolini Delgado's avatar Armando Luiz Nicolini Delgado :nerd:
Browse files

* Adicionada função 'markerName' para gerar nomes de marcadores LIKWID

parent 2352e750
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "utils.h"
......@@ -18,3 +20,16 @@ double timestamp(void)
clock_gettime(CLOCK_MONOTONIC_RAW, &tp);
return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6));
}
string_t markerName(string_t baseName, int n)
{
string_t mark = (string_t) malloc( (strlen(baseName)+1) + (log10(n)+1) + 1 );
sprintf(mark, "%s_%u", baseName,n);
// printf("*** %s\n", mark);
return mark;
}
......@@ -4,7 +4,13 @@
#include <stdlib.h>
#include <time.h>
typedef double real_t;
typedef double rtime_t;
typedef char * string_t;
double timestamp(void);
string_t markerName(string_t baseName, int n);
#endif // __UTILS_H__
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "utils.h"
/* Retorna tempo em milisegundos
......@@ -13,9 +16,20 @@
double timestamp(void)
{
struct timeval tp;
gettimeofday(&tp, NULL);
// printf("\n*** %7.10lf ms %7.10lf ms\n", tp.tv_sec*1.0e3, tp.tv_usec*1.0e-3);
return((double)(tp.tv_sec*1.0e3 + tp.tv_usec*1.0e-3));
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC_RAW, &tp);
return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6));
}
string_t markerName(string_t baseName, int n)
{
string_t mark = (string_t) malloc( (strlen(baseName)+1) + (log10(n)+1) + 1 );
sprintf(mark, "%s_%u", baseName,n);
// printf("*** %s\n", mark);
return mark;
}
......@@ -2,9 +2,15 @@
#define __UTILS_H__
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
typedef double real_t;
typedef double rtime_t;
typedef char * string_t;
double timestamp(void);
string_t markerName(string_t baseName, int n);
#endif // __UTILS_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment