From 5effe82dd4eab44125f5720dcb912e99bd1f9e05 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 18 Oct 2015 10:52:59 +0200 Subject: [PATCH] fix time handling - add implementation for RCCE_wtime - use system call to determine the clock frequency --- hermit/usr/ircce/RCCE_admin.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/hermit/usr/ircce/RCCE_admin.c b/hermit/usr/ircce/RCCE_admin.c index 37e0cc165..58e643632 100644 --- a/hermit/usr/ircce/RCCE_admin.c +++ b/hermit/usr/ircce/RCCE_admin.c @@ -45,6 +45,7 @@ #else #define RCCE_SESSION_ID 42 #include "syscall.h" + extern unsigned int get_cpufreq(); #endif #endif #include @@ -190,7 +191,15 @@ t_vcharp RCCE_fool_write_combine_buffer; //...................................................................................... #ifdef SCC -#ifndef __INTEL_COMPILER +#ifdef __hermit__ +inline volatile uint64_t _rdtsc() { + uint64_t lo, hi; + + asm volatile ("rdtsc" : "=a"(lo), "=d"(hi) ); + + return ((uint64_t)hi << 32ULL | (uint64_t)lo); +} +#elif defined(__INTEL_COMPILER) inline volatile long long _rdtsc() { register long long TSC __asm__("eax"); __asm__ volatile (".byte 15, 49" : : : "eax", "edx"); @@ -248,7 +257,14 @@ int RC_COMM_BUFFER_SIZE() { //-------------------------------------------------------------------------------------- t_vcharp RC_COMM_BUFFER_START(int ue){ #ifdef __hermit__ - return (t_vcharp) SYSCALL2(__NR_rcce_malloc, RCCE_SESSION_ID, ue); + t_vcharp retval; + retval = (t_vcharp) SYSCALL2(__NR_rcce_malloc, RCCE_SESSION_ID, ue); + if (!retval) { + fprintf(stderr, "rcce_malloc failed\n"); + RCCE_finalize(); + exit(1); + } + return retval; #elif defined(SCC) // "Allocate" MPB, using memory mapping of physical addresses t_vcharp retval; @@ -878,7 +894,14 @@ int RCCE_init( #endif RCCE_NP = atoi(*(++(*argv))); +#ifdef __hermit__ + // HermitCore ignores the third argument and uses + // its own clock value + RC_REFCLOCKGHZ = (double) get_cpufreq() / 1000.0; + ++(*argv); +#else RC_REFCLOCKGHZ = atof(*(++(*argv))); +#endif // put the participating core ids (unsorted) into an array for (ue=0; ue