Skip to content

Add support for compiling on other architectures (DSP-172) #114

@coderforlife

Description

@coderforlife

Is your feature request related to a problem?

Currently the library can used for testing on Linux with x86_64 due to the code at

// Linux Target
#include <x86intrin.h>
#define dsp_get_cpu_cycle_count __rdtsc
.

Describe the solution you'd like.

However, this could be easily adjusted to support other architectures by using some of the following:

  • If the compiler is clang, it always has __builtin_readcyclecounter() which works on any architecture that supports it (x86, ARM, etc). On x86_64 it is equivalent to __rdtsc().
  • Using PMCCNTR on most ARM architectures (but only under certain circumstances).
  • Falling back to the vDSO clock_gettime(CLOCK_MONOTONIC) which is slightly slower than __rdtsc() due to conversion to nanoseconds.

A very complete system is outlined at https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h but that is likely overkill.

Another solution would be to disable all timing codes if necessary.

Describe alternatives you've considered.

I modified the dsp_common.h header myself to use __builtin_readcyclecounter() in my environment and to not include the intrinsics file (which is the real problem on other architectures).

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions