tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 1 | #include "Platform.h" |
2 | |||||
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 3 | #include <stdio.h> |
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 4 | |
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 5 | void testRDTSC ( void ) |
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 6 | { |
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 7 | int64_t temp = rdtsc(); |
8 | |||||
9 | printf("%d",(int)temp); | ||||
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 10 | } |
11 | |||||
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 12 | #if defined(_MSC_VER) |
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 13 | |
14 | #include <windows.h> | ||||
15 | |||||
16 | void SetAffinity ( int cpu ) | ||||
17 | { | ||||
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 18 | SetProcessAffinityMask(GetCurrentProcess(),cpu); |
tanjent@gmail.com | 0f37bbd | 2011-04-04 23:05:26 +0000 | [diff] [blame] | 19 | SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); |
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 20 | } |
21 | |||||
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 22 | #else |
23 | |||||
aappleby@google.com | 4bbda98 | 2011-04-04 23:38:12 +0000 | [diff] [blame] | 24 | #include <sched.h> |
25 | |||||
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 26 | void SetAffinity ( int /*cpu*/ ) |
27 | { | ||||
tanjent@gmail.com | 510b852 | 2011-04-12 15:36:18 +0000 | [diff] [blame] | 28 | #ifndef __CYGWIN__ |
aappleby@google.com | 4bbda98 | 2011-04-04 23:38:12 +0000 | [diff] [blame] | 29 | cpu_set_t mask; |
30 | |||||
31 | CPU_ZERO(&mask); | ||||
32 | |||||
33 | CPU_SET(2,&mask); | ||||
34 | |||||
35 | if( sched_setaffinity(0,sizeof(mask),&mask) == -1) | ||||
36 | { | ||||
37 | printf("WARNING: Could not set CPU affinity\n"); | ||||
38 | } | ||||
tanjent@gmail.com | 510b852 | 2011-04-12 15:36:18 +0000 | [diff] [blame] | 39 | #endif |
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 40 | } |
41 | |||||
42 | #endif |