simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.37k stars 247 forks source link

rdtsc (feature request) #941

Open jeffhammond opened 2 years ago

jeffhammond commented 2 years ago

I find _rdtsc, __rdtsc, and/or _rdtscp in a lot of code that uses x86 intrinsics.

I requested this feature from SSE2Neon (https://github.com/DLTcollab/sse2neon/issues/472) and some folks suggested an implementation for ARM.

A PowerPC implementation is https://www.mcs.anl.gov/~kazutomo/rdtsc.h (I can ask the author to contribute to avoid any license questions).

Thanks.

nemequ commented 2 years ago

rdtsc may be a better fit for the builtin module in portable-snippets. It's mostly focused on generic built-ins (i.e., __builtin_bswap32 not _byteswap_ulong), but there are a few x86-style instrinsics as well (including _byteswap_ulong).

I'm not sure I want to be adding too many non-SIMD intrinsics to SIMDe; _mm_malloc etc. make sense, but rdtsc makes less sense... I'm not saying "no" yet, but I'm leaning in that direction.

Another possibility would be a new project for the non-SIMD intrinsics. I'd be happy to fold the builtins module from psnip into that project, of course, and we could steal from SIMDe when it made sense (things like CPU detection). There is even an obvious name for the project: "extrinsic" ;)

What does everyone else think?

jeffhammond commented 2 years ago

I find that usage of RDTSC correlates strongly with SIMD intrinsics, and I like to minimize the number of dependencies I have to include, so I'd vote to just pull this small set of features into this project, the way SSE2Neon has done, but as I'm probably not going to be the one doing the work, my vote should be scaled appropriately.

On the other hand, if "extrinsic" were a git submodule of simde, I probably wouldn't notice, but I'm not a huge fan of git submodules in general.