LAPACK Archives

[Lapack] lapack + LLVM: variant on second_()


As part of our bring-up of a new architecture (we use LLVM exclusively) I found 
it useful to create a new variant of the second_() routine: second_CYCLE_TIME.c 
 Here is the source in case others find a need to capture cycle times (instead 
of wall clock times)

Regards,
        Richard

------------
//
// Cognitive wrapper for dealing with the Fortran CPU_TIME intrinsic.
// Grab the cycle counter, and return it as a float or double, just like
// the fortran code does.
#include <stdint.h>

#if !defined(__llvm__)
#if defined (__x86_64)
uint64_t __builtin_readcyclecounter()
{
    uint32_t hi, lo;
    __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    return ( ((uint64_t)lo) | (((uint64_t)hi)<<32) );
}
#else
#error Need an implementation of __builtin_readcyclecounter
#endif
#endif

float second_()
{
    float       result;
    uint64_t    cycles = __builtin_readcyclecounter();

    result = (float) cycles;

    return result;
}


<Prev in Thread] Current Thread [Next in Thread>
  • [Lapack] lapack + LLVM: variant on second_(), Richard Gorton <=


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or