Skip to content

Commit

Permalink
Add flag for optimising for specific CPU (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker authored Mar 14, 2022
1 parent 1734200 commit 3cad81a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 43 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ option(FAABRIC_WASM_BUILD "Build Faabric wasm library" OFF)
option(FAABRIC_BUILD_TESTS "Build Faabric tests" ON)
option(FAABRIC_SELF_TRACING "Turn on system tracing using the logger" OFF)

option(FAABRIC_TARGET_CPU "CPU to optimise for, e.g. skylake, icelake or native" OFF)

# Enable colorized compiler output
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
Expand All @@ -13,7 +15,12 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif()

# Optimise for CPU
include(cmake/OptimiseCPU.cmake)
if(FAABRIC_TARGET_CPU)
message(STATUS "Optimising Faabric for CPU ${FAABRIC_TARGET_CPU}")
add_compile_options(-march=${FAABRIC_TARGET_CPU} -mtune=${FAABRIC_TARGET_CPU})
else()
message(STATUS "Faabric not optimised for specific CPU")
endif()

# Top-level CMake config
set(CMAKE_CXX_FLAGS "-Wall")
Expand Down
41 changes: 0 additions & 41 deletions cmake/OptimiseCPU.cmake

This file was deleted.

9 changes: 8 additions & 1 deletion tasks/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@

@task
def cmake(
ctx, clean=False, shared=False, build="Debug", sanitiser="None", prof=False
ctx,
clean=False,
shared=False,
build="Debug",
sanitiser="None",
prof=False,
cpu=None,
):
"""
Configures the build
Expand Down Expand Up @@ -44,6 +50,7 @@ def cmake(
"-DCMAKE_C_COMPILER=/usr/bin/clang-13",
"-DFAABRIC_USE_SANITISER={}".format(sanitiser),
"-DFAABRIC_SELF_TRACING=ON" if prof else "",
"-DFAABRIC_TARGET_CPU={}".format(cpu) if cpu else "",
PROJ_ROOT,
]

Expand Down

0 comments on commit 3cad81a

Please sign in to comment.