r5:
new parameter "opt"
opt: call the fastest possible functions if opt=True, else call the C++ functions.
Quote:
Originally Posted by Myrsloik
Just copy those files into your own project. Done.
|
Quote:
Originally Posted by TheFluff
|
Tried to use them but got stuck at "cpu.asm", apparently it requires nasm or yasm and these 2 are real pain in the ass, I wasted hours trying to make them work on VS2017 and all I got was millions of errors popping out relentlessly...
I even thought about translating "cpu.asm" to masm, and obviously I would have to translate "x86inc.asm" along with it, and that's a big NO.
so I merged those 3 into one file, "
cpufeatures.hpp", and wrote my own version of CPUFeatures, with absolutely no trace of (literal) asm.
these 2 functions:
Code:
vs_cpu_cpuid()
vs_cpu_xgetbv()
have been integrated into the compiler,
Code:
Visual Studio 2017:
vs_cpu_cpuid() -> __cpuid()
GCC:
vs_cpu_cpuid() -> __get_cpuid()
vs_cpu_xgetbv() -> _xgetbv() //defined in immintrin.h
so I think there's no need to write literal asm for them.
and I canceled the "getCPUFeatures()" function, it could be simply integrated into the constructor since I'm using a C++ header.
so instead of
Code:
CPUFeatures CPU;
getCPUFeatures(&CPU);
if (CPU.fma3)
xxx
it's now cleaner like
Code:
auto CPU = CPUFeatures();
if (CPU.fma3)
xxx