Browse Source

merge trunk

Samuel Thibault 10 years ago
parent
commit
530c6417aa
3 changed files with 39 additions and 8 deletions
  1. 0 1
      include/pthread_win32/pthread.h
  2. 4 2
      include/starpu_thread_util.h
  3. 35 5
      tests/loader.c

+ 0 - 1
include/pthread_win32/pthread.h

@@ -33,7 +33,6 @@ extern "C" {
 
 #include <windows.h>
 #include <sys/types.h>
-#undef interface
 #include <stdio.h>
 #include <errno.h>
 

+ 4 - 2
include/starpu_thread_util.h

@@ -21,6 +21,7 @@
 #include <starpu_util.h>
 #include <errno.h>
 
+#if !(defined(_MSC_VER) && !defined(BUILDING_STARPU))
 /*
  * Encapsulation of the starpu_pthread_create_* functions.
  */
@@ -80,9 +81,9 @@
 } while (0)
 
 #define STARPU_PTHREAD_MUTEX_TRYLOCK(mutex) \
-	_STARPU_PTHREAD_MUTEX_TRYLOCK(mutex, __FILE__, __LINE__)
+	_starpu_pthread_mutex_trylock(mutex, __FILE__, __LINE__)
 static STARPU_INLINE
-int _STARPU_PTHREAD_MUTEX_TRYLOCK(starpu_pthread_mutex_t *mutex, char *file, int line)
+int _starpu_pthread_mutex_trylock(starpu_pthread_mutex_t *mutex, char *file, int line)
 {
 	int p_ret = starpu_pthread_mutex_trylock(mutex);
 	if (STARPU_UNLIKELY(p_ret != 0 && p_ret != EBUSY)) {
@@ -305,5 +306,6 @@ int _starpu_pthread_rwlock_trywrlock(starpu_pthread_rwlock_t *rwlock, char *file
 			STARPU_ABORT();                                        \
 	}                                                                      \
 } while (0)
+#endif /* _MSC_VER */
 
 #endif /* __STARPU_THREAD_UTIL_H__ */

+ 35 - 5
tests/loader.c

@@ -26,12 +26,42 @@
 #include <signal.h>
 #include <string.h>
 
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
 #define  DEFAULT_TIMEOUT       600
 #define  AUTOTEST_SKIPPED_TEST 77
 
 static pid_t child_pid = 0;
 static int   timeout;
 
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+static int mygettimeofday(struct timeval *tv, void *tz)
+{
+	if (tv)
+	{
+		FILETIME ft;
+		unsigned long long res;
+		GetSystemTimeAsFileTime(&ft);
+		/* 100-nanosecond intervals since January 1, 1601 */
+		res = ft.dwHighDateTime;
+		res <<= 32;
+		res |= ft.dwLowDateTime;
+		res /= 10;
+		/* Now we have microseconds */
+		res -= (((1970-1601)*365) + 89) * 24ULL * 3600ULL * 1000000ULL;
+		/* Now we are based on epoch */
+		tv->tv_sec = res / 1000000ULL;
+		tv->tv_usec = res % 1000000ULL;
+	}
+}
+#else
+#define mygettimeofday(tv,tz) gettimeofday(tv,tz)
+#endif
+
 static void launch_gdb(const char *exe)
 {
 #ifdef STARPU_GDB_PATH
@@ -169,8 +199,8 @@ int main(int argc, char *argv[])
 	char *launcher_args;
 	struct sigaction sa;
 	int   ret;
-	double start;
-	double end;
+	struct timeval start;
+	struct timeval end;
 	double timing;
 
 	test_args = NULL;
@@ -280,7 +310,7 @@ int main(int argc, char *argv[])
 	}
 
 	ret = EXIT_SUCCESS;
-	start = starpu_timing_now();
+	gettimeofday(&start, NULL);
 	alarm(timeout);
 	if (child_pid == waitpid(child_pid, &child_exit_status, 0))
 	{
@@ -314,8 +344,8 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	end = starpu_timing_now();
-	timing = end - start;
+	gettimeofday(&end, NULL);
+	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	fprintf(stderr, "#Execution_time_in_seconds %f %s\n", timing/1000000, test_name);
 
 	return ret;