Platform.cpp 659 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "Platform.h"
  2. #include <stdio.h>
  3. void testRDTSC ( void )
  4. {
  5. int64_t temp = rdtsc();
  6. printf("%d",(int)temp);
  7. }
  8. #if defined(_MSC_VER)
  9. #include <windows.h>
  10. void SetAffinity ( int cpu )
  11. {
  12. SetProcessAffinityMask(GetCurrentProcess(),cpu);
  13. SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
  14. }
  15. #else
  16. #include <sched.h>
  17. void SetAffinity ( int /*cpu*/ )
  18. {
  19. #if !defined(__CYGWIN__) && !defined(__APPLE__) && !defined(__FreeBSD__)
  20. cpu_set_t mask;
  21. CPU_ZERO(&mask);
  22. CPU_SET(2,&mask);
  23. if( sched_setaffinity(0,sizeof(mask),&mask) == -1)
  24. {
  25. printf("WARNING: Could not set CPU affinity\n");
  26. }
  27. #endif
  28. }
  29. #endif