Skip to content

Commit

Permalink
Merge pull request #301 from ABRG-Models/dev/lose_march_native
Browse files Browse the repository at this point in the history
Lose -march=native which can cause problems
  • Loading branch information
sebjameswml authored Dec 5, 2024
2 parents 970a3c9 + 6afb527 commit 3d2109e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ else()
endif()
endif()
set(COMPREHENSIVE_WARNING_FLAGS "-Wall -Wextra -Wpedantic -pedantic-errors -Werror -Wfatal-errors -Wno-psabi")
set(CMAKE_CXX_FLAGS "${MORPH_HOST_DEFINITION} -g ${COMPREHENSIVE_WARNING_FLAGS} -march=native -O3")
set(CMAKE_CXX_FLAGS "${MORPH_HOST_DEFINITION} -g ${COMPREHENSIVE_WARNING_FLAGS} -O3")
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
# Make it possible to compile complex constexpr functions (gcc only)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=5000000000")
Expand Down
2 changes: 1 addition & 1 deletion README.cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ set(CMAKE_CXX_STANDARD 17)
if (APPLE)
set(CMAKE_CXX_FLAGS "${EXTRA_HOST_DEFINITION} -Wall -Wfatal-errors -g -O3")
else() # assume g++ (or a gcc/g++ mimic like Clang)
set(CMAKE_CXX_FLAGS "${EXTRA_HOST_DEFINITION} -Wall -Wfatal-errors -g -Wno-unused-result -Wno-unknown-pragmas -march=native -O3")
set(CMAKE_CXX_FLAGS "${EXTRA_HOST_DEFINITION} -Wall -Wfatal-errors -g -Wno-unused-result -Wno-unknown-pragmas -O3")
endif()
# Tell clang to be quiet about brace initialisers:
Expand Down
2 changes: 1 addition & 1 deletion README.coding.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cd /home/seb/models/morphologica/examples
-D__GLN__ -DGL3_PROTOTYPES -DGL_GLEXT_PROTOTYPES \ # Important flags to set
-DMORPH_FONTS_DIR="\"/home/seb/models/morphologica/fonts\"" \
-Wall -g -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas \ # Almost all warnings
-march=native -O3 -fopenmp -std=gnu++17 \ # More compiler flags
-O3 -fopenmp -std=gnu++17 \ # More compiler flags
-o helloworld helloworld.cpp \ # Input code file and name for output
/usr/lib/x86_64-linux-gnu/libglfw.so.3.3 \ # Links to shared libraries
/usr/lib/x86_64-linux-gnu/libfreetype.so \
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/visual/visual.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ You can see how this works in the [myvisual.cpp](https://github.com/ABRG-Models/

# Working with multiple windows

You can create more than one `morph::Visual` in your program. Each `Visual` will be related to a separate OpenGL context. morphoglogica will handle the switching of the context automatically (by calling `Visual::setContext()` as needed, for example if you call `Visual::render()`).
You can create more than one `morph::Visual` in your program. Each `Visual` will be related to a separate OpenGL context. morphologica will handle the switching of the context automatically (by calling `Visual::setContext()` as needed, for example if you call `Visual::render()`).

![Screenshot of two computer windows each backed by a morph::Visual](https://github.com/ABRG-Models/morphologica/blob/main/docs/images/morph_two_visuals.png?raw=true)

Expand Down
4 changes: 2 additions & 2 deletions standalone_examples/elmannet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3")
else()
if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -march=native -O3 -D__ICC__")
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3 -D__ICC__")
else () # GCC or Clang
# This assumes a gcc compiler (or a gcc mimic like Clang)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -march=native -O3")
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3")
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions standalone_examples/neuralnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3")
else()
if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -march=native -O3 -D__ICC__")
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3 -D__ICC__")
else () # GCC or Clang
# This assumes a gcc compiler (or a gcc mimic like Clang)
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -march=native -O3")
set(CMAKE_CXX_FLAGS "${FLAGS_COMMON} -O3")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion standalone_examples/recurrentnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
# This assumes a gcc compiler (or a gcc mimic like Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unknown-pragmas -march=native -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unknown-pragmas -O3")
endif()

# Tell clang to be quiet about brace initialisers:
Expand Down
2 changes: 1 addition & 1 deletion standalone_examples/schnakenberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3")
else()
# This assumes a gcc compiler (or a gcc mimic like Clang)
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3 -Wno-unused-result -Wno-unknown-pragmas -march=native")
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3 -Wno-unused-result -Wno-unknown-pragmas")
endif()

# Tell clang to be quiet about brace initialisers:
Expand Down
2 changes: 1 addition & 1 deletion standalone_examples/template/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3")
else()
# This assumes a gcc compiler (or a gcc mimic like Clang)
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3 -Wno-unused-result -Wno-unknown-pragmas -march=native")
set(CMAKE_CXX_FLAGS "${OS_FLAG} -Wall -Wfatal-errors -g -O3 -Wno-unused-result -Wno-unknown-pragmas")
endif()

# Tell clang to be quiet about brace initialisers:
Expand Down
12 changes: 6 additions & 6 deletions tests/testarange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ int main()
morph::vvec<double> x_ex1 = { 0.0 , 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5 };
x.arange (0.0, 6.0, 0.5);
std::cout << "First example: " << x << std::endl;
if (std::abs((x - x_ex1).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex1).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }

// x = np.arange(-2.5, 2.3, 2)
morph::vvec<double> x_ex2 = { -2.5, -0.5, 1.5 };
x.arange (-2.5, 2.3, 2.0);
std::cout << "Second example: " << x << std::endl;
if (std::abs((x - x_ex2).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex2).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }

// x = np.arange(-5, 5, 2)
morph::vvec<double> x_ex3 = { -5.0, -3.0, -1.0, 1.0, 3.0 };
x.arange (-5.0, 5.0, 2.0);
std::cout << "Third example: " << x << std::endl;
if (std::abs((x - x_ex3).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex3).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }

// x = np.arange(2, -2, 0.27) (should be empty)
morph::vvec<double> x_ex4 = {};
Expand All @@ -40,19 +40,19 @@ int main()
morph::vvec<double> x_ex6 = { 1.0, 0.8, 0.6, 0.4, 0.2, 0.0, -0.2, -0.4, -0.6, -0.8 };
x.arange (1.0, -1.0, -0.2);
std::cout << "Sixth example: " << x << std::endl;
if (std::abs((x - x_ex6).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex6).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }

// x = np.arange(-2, 1.2, 0.3)
morph::vvec<double> x_ex7 = { -2.0 , -1.7, -1.4, -1.1, -0.8, -0.5, -0.2, 0.1, 0.4, 0.7, 1.0 };
x.arange (-2.0, 1.2, 0.3);
std::cout << "Seventh example: " << x << std::endl;
if (std::abs((x - x_ex7).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex7).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }

// x = np.arange(1, 3, 2.1) (increment greater than gap)
morph::vvec<double> x_ex8 = { 1.0 };
x.arange (1.0, 3.0, 2.1);
std::cout << "Eighth example: " << x << std::endl;
if (std::abs((x - x_ex8).longest()) >= std::numeric_limits<double>::epsilon()) { --rtn; }
if (std::abs((x - x_ex8).longest()) > std::numeric_limits<double>::epsilon()) { --rtn; }


if (rtn == 0) { std::cout << "Success\n"; }
Expand Down

0 comments on commit 3d2109e

Please sign in to comment.