Skip to content

Commit

Permalink
fix build for x86 and arm (#110)
Browse files Browse the repository at this point in the history
* fix the right define

* fixed the include

* removed cpu_features macros include

* incdlue cpu_features macros

* fixed x86 build
  • Loading branch information
DvirDukhan authored Jan 5, 2022
1 parent b4dfb45 commit 112b7ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/VecSim/spaces/space_aux.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "space_aux.h"
#include "cpu_features_macros.h"

#ifdef CPU_FEATURES_ARCH_X86_64
#include "cpuinfo_x86.h"
#endif // CPU_FEATURES_ARCH_X86_64

Arch_Optimization getArchitectureOptimization() {

#ifdef CPU_FEATURES_ARCH_X86
#ifdef CPU_FEATURES_ARCH_X86_64
#include "cpuinfo_x86.h"
cpu_features::X86Features features = cpu_features::GetX86Info().features;
if (features.avx512f) {
Expand All @@ -13,7 +18,7 @@ Arch_Optimization getArchitectureOptimization() {
features.sse4_2 || features.sse4a) {
return ARCH_OPT_SSE;
}
#endif // CPU_FEATURES_ARCH_X86
#endif // CPU_FEATURES_ARCH_X86_64

return ARCH_OPT_NONE;
}
5 changes: 3 additions & 2 deletions tests/unit/test_spaces.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "gtest/gtest.h"
#include "cpu_features_macros.h"
#include "VecSim/spaces/space_aux.h"
#include "VecSim/spaces/IP/IP.h"
#include "VecSim/spaces/IP/IP_SSE.h"
Expand All @@ -21,7 +22,7 @@ class SpacesTest : public ::testing::Test {
void TearDown() override {}
};

#ifdef CPU_FEATURES_ARCH_X86
#ifdef CPU_FEATURES_ARCH_X86_64
// This test will trigger the "Residuals" function for dimension > 16, for each optimization.
TEST_F(SpacesTest, l2_17) {
Arch_Optimization optimization = getArchitectureOptimization();
Expand Down Expand Up @@ -121,4 +122,4 @@ TEST_F(SpacesTest, ip_9) {
ASSERT_TRUE(false);
}
}
#endif // CPU_FEATURES_ARCH_X86
#endif // CPU_FEATURES_ARCH_X86_64

0 comments on commit 112b7ea

Please sign in to comment.