Skip to content

Commit

Permalink
vectorizing the vec.h math header with std::simd, nice :)
Browse files Browse the repository at this point in the history
  • Loading branch information
MajidAbdelilah committed Nov 5, 2024
1 parent 58928e1 commit 2a266d2
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ project(Physics3D-application VERSION 1.0)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Building with: ${CMAKE_CXX_COMPILER_ID}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Oi /ot /GL")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fsanitize=address")

Expand Down
6 changes: 3 additions & 3 deletions Physics3D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ cmake_minimum_required(VERSION 3.10)
project(Physics3D VERSION 0.9)


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Oi /ot /GL")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fno-math-errno")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native -fno-math-errno")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")

#running benchmarks showed this to be a pessimization
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION True)
Expand Down
2 changes: 1 addition & 1 deletion Physics3D/geometry/triangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ MeshPrototype::MeshPrototype(int vertexCount, int triangleCount, UniqueAlignedPo
triangleCount(triangleCount) {}

Vec3f MeshPrototype::getVertex(int index) const {
assert(index >= 0 && index < vertexCount);
// assert(index >= 0 && index < vertexCount);
size_t currect_index = (index / BLOCK_WIDTH) * BLOCK_WIDTH * 2 + index;
return Vec3f(this->vertices[currect_index], this->vertices[currect_index + BLOCK_WIDTH], this->vertices[currect_index + BLOCK_WIDTH * 2]);
}
Expand Down
Loading

0 comments on commit 2a266d2

Please sign in to comment.