1 /* clock.c 2 * Support file for nvptx in newlib. 3 */ 4 #include <time.h> 5 6 clock_t clock()7clock () 8 { 9 unsigned long long now; 10 #if __PTX_SM__ >= 310 11 asm volatile("mov.u64 %0, %%globaltimer;" : "=r"(now)); 12 return now/((1000000000ull)/CLOCKS_PER_SEC); 13 #else 14 asm volatile("mov.u64 %0, %%clock64;" : "=r"(now)); 15 // Assume a GPU base clock frequency of 1250MHz. 16 return now/((1250000000ull)/CLOCKS_PER_SEC); 17 #endif 18 } 19