Skip to content

Commit

Permalink
feat: add patches and edit makefile to apply them if on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
roelofvandijkO committed May 12, 2024
1 parent 41a8ceb commit 27172b8
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 1 deletion.
57 changes: 57 additions & 0 deletions 3rdparty/homography.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/3rdparty/homography/LibHomography/Splines.h b/3rdparty/homography/LibHomography/Splines.h
index 56a36f1..46a123d 100644
--- a/3rdparty/homography/LibHomography/Splines.h
+++ b/3rdparty/homography/LibHomography/Splines.h
@@ -5,8 +5,7 @@
//! Global includes
#include <cstdlib>
#include <cmath>
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../sse2neon/sse2neon.h"


//! Local includes
diff --git a/3rdparty/homography/LibImages/LibImages.cpp b/3rdparty/homography/LibImages/LibImages.cpp
index 7c1f6f5..fd75fb4 100644
--- a/3rdparty/homography/LibImages/LibImages.cpp
+++ b/3rdparty/homography/LibImages/LibImages.cpp
@@ -14,8 +14,7 @@
#ifdef _OPENMP
#include <omp.h>
#endif
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../sse2neon/sse2neon.h"
#include <cmath>
#include <algorithm>
#include <cstring>
diff --git a/3rdparty/homography/LibImages/LibImages.h b/3rdparty/homography/LibImages/LibImages.h
index 51233a3..8ae589d 100644
--- a/3rdparty/homography/LibImages/LibImages.h
+++ b/3rdparty/homography/LibImages/LibImages.h
@@ -5,8 +5,7 @@
#include <stdlib.h>
#include <string>
#include <vector>
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../sse2neon/sse2neon.h"

//! Local includes

diff --git a/3rdparty/homography/Utilities/Utilities.h b/3rdparty/homography/Utilities/Utilities.h
index cc80a22..ee45bf9 100644
--- a/3rdparty/homography/Utilities/Utilities.h
+++ b/3rdparty/homography/Utilities/Utilities.h
@@ -8,8 +8,8 @@
#include <sstream>
#include <iostream>
#include <iomanip>
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../sse2neon/sse2neon.h"
+
#include <vector>


15 changes: 15 additions & 0 deletions 3rdparty/iio.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/3rdparty/iio/iio.c b/3rdparty/iio/iio.c
index 5bff3d8..67b06ac 100644
--- a/3rdparty/iio/iio.c
+++ b/3rdparty/iio/iio.c
@@ -535,7 +535,9 @@ int iio_type_id(size_t sample_size, bool ieeefp_sample, bool signed_sample)
switch(sample_size) {
case sizeof(float): return IIO_TYPE_FLOAT;
case sizeof(double): return IIO_TYPE_DOUBLE;
- case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #ifdef I_CAN_HAS_LONGDOUBLE
+ case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #endif//I_CAN_HAS_LONGDOUBLE
case sizeof(float)/2: return IIO_TYPE_HALF;
default: fail("bad float size %zu", sample_size);
}
15 changes: 15 additions & 0 deletions 3rdparty/imscript.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/3rdparty/imscript/src/iio.c b/3rdparty/imscript/src/iio.c
index 2516713..8428556 100644
--- a/3rdparty/imscript/src/iio.c
+++ b/3rdparty/imscript/src/iio.c
@@ -535,7 +535,9 @@ int iio_type_id(size_t sample_size, bool ieeefp_sample, bool signed_sample)
switch(sample_size) {
case sizeof(float): return IIO_TYPE_FLOAT;
case sizeof(double): return IIO_TYPE_DOUBLE;
- case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #ifdef I_CAN_HAS_LONGDOUBLE
+ case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #endif//I_CAN_HAS_LONGDOUBLE
case sizeof(float)/2: return IIO_TYPE_HALF;
default: fail("bad float size %zu", sample_size);
}
15 changes: 15 additions & 0 deletions 3rdparty/mgm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/3rdparty/mgm/iio/iio.c b/3rdparty/mgm/iio/iio.c
index 4a678db..33de681 100644
--- a/3rdparty/mgm/iio/iio.c
+++ b/3rdparty/mgm/iio/iio.c
@@ -489,7 +489,9 @@ int iio_type_id(size_t sample_size, bool ieeefp_sample, bool signed_sample)
switch(sample_size) {
case sizeof(float): return IIO_TYPE_FLOAT;
case sizeof(double): return IIO_TYPE_DOUBLE;
- case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #ifdef I_CAN_HAS_LONGDOUBLE
+ case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #endif//I_CAN_HAS_LONGDOUBLE
case sizeof(float)/2: return IIO_TYPE_HALF;
default: fail("bad float size %zu", sample_size);
}
17 changes: 17 additions & 0 deletions 3rdparty/mgm_multi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/3rdparty/mgm_multi/iio/iio.c b/3rdparty/mgm_multi/iio/iio.c
index 9f28831..7475497 100644
--- a/3rdparty/mgm_multi/iio/iio.c
+++ b/3rdparty/mgm_multi/iio/iio.c
@@ -511,8 +511,10 @@ int iio_type_id(size_t sample_size, bool ieeefp_sample, bool signed_sample)
switch(sample_size) {
case sizeof(float): return IIO_TYPE_FLOAT;
case sizeof(double): return IIO_TYPE_DOUBLE;
- case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
- case sizeof(float)/2: return IIO_TYPE_HALF;
+ #ifdef I_CAN_HAS_LONGDOUBLE
+ case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #endif//I_CAN_HAS_LONGDOUBLE
+ case sizeof(float)/2: return IIO_TYPE_HALF;
default: fail("bad float size %zu", sample_size);
}
} else {
28 changes: 28 additions & 0 deletions 3rdparty/sift.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/3rdparty/sift/simd/LibImages/LibImages.cpp b/3rdparty/sift/simd/LibImages/LibImages.cpp
index 6acbe4e..870d80b 100644
--- a/3rdparty/sift/simd/LibImages/LibImages.cpp
+++ b/3rdparty/sift/simd/LibImages/LibImages.cpp
@@ -10,8 +10,7 @@
#ifdef _OPENMP
#include <omp.h>
#endif
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../sse2neon/sse2neon.h"
#include <cmath>
#include <algorithm>
#include <cstring>
diff --git a/3rdparty/sift/simd/LibImages/LibImages.h b/3rdparty/sift/simd/LibImages/LibImages.h
index 9918472..c8c5db1 100644
--- a/3rdparty/sift/simd/LibImages/LibImages.h
+++ b/3rdparty/sift/simd/LibImages/LibImages.h
@@ -5,8 +5,7 @@
#include <stdlib.h>
#include <string>
#include <vector>
-#include <xmmintrin.h>
-#include <x86intrin.h>
+#include "../../../sse2neon/sse2neon.h"

//! Local includes

15 changes: 15 additions & 0 deletions 3rdparty/tvl1flow.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/3rdparty/tvl1flow/iio.c b/3rdparty/tvl1flow/iio.c
index 9f28831..e27955e 100644
--- a/3rdparty/tvl1flow/iio.c
+++ b/3rdparty/tvl1flow/iio.c
@@ -511,7 +511,9 @@ int iio_type_id(size_t sample_size, bool ieeefp_sample, bool signed_sample)
switch(sample_size) {
case sizeof(float): return IIO_TYPE_FLOAT;
case sizeof(double): return IIO_TYPE_DOUBLE;
- case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #ifdef I_CAN_HAS_LONGDOUBLE
+ case sizeof(long double): return IIO_TYPE_LONGDOUBLE;
+ #endif//I_CAN_HAS_LONGDOUBLE
case sizeof(float)/2: return IIO_TYPE_HALF;
default: fail("bad float size %zu", sample_size);
}
24 changes: 23 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
UNAME := $(shell uname)

# the following two options are used to control all C and C++ compilations
CFLAGS ?= -march=native -O3
CXXFLAGS ?= -march=native -O3

ifeq ($(UNAME), Darwin)
# on Mac OS, use recommended flag for sse2neon
CFLAGS ?= -march=armv8-a+fp+simd+crypto+crc -O3
CXXFLAGS ?= -march=armv8-a+fp+simd+crypto+crc -O3
endif

export CFLAGS
export CXXFLAGS

ifeq ($(UNAME), Darwin)
# on mac, also link to homebrew
export C_INCLUDE_PATH := ${C_INCLUDE_PATH}:/opt/homebrew/include
export CPLUS_INCLUDE_PATH := ${CPLUS_INCLUDE_PATH}:/opt/homebrew/include
export LIBRARY_PATH := ${LIBRARY_PATH}:/opt/homebrew/lib
export LD_LIBRARY_PATH := ${LD_LIBRARY_PATH}:/opt/homebrew/lib
# apply patches, ignore if they fail (already patched)
patch_osx = git apply 3rdparty/*.patch || true
endif

# these options are only used for the programs directly inside "./c/"
IIOLIBS = -lz -ltiff -lpng -ljpeg -lm


# default rule builds only the programs necessary for the test
default: homography sift mgm_multi tvl1 lsd executables libraries
default: patch_osx homography sift mgm_multi tvl1 lsd executables libraries

# the "all" rule builds three further correlators
all: default msmw3 sgbm
Expand All @@ -22,6 +41,9 @@ test: default
# four standard "modules": homography, sift, mgm, and mgm_multi
#

patch_osx:
$(patch_osx)

homography:
$(MAKE) -j -C 3rdparty/homography
cp 3rdparty/homography/homography bin
Expand Down

0 comments on commit 27172b8

Please sign in to comment.