Algebraic-Programming / ALP

Home of ALP/GraphBLAS and ALP/Pregel, featuring shared- and distributed-memory auto-parallelisation of linear algebraic and vertex-centric programs. Soon with more to come!
Apache License 2.0
25 stars 4 forks source link

Detect architecture features automatically #327

Open alberto-scolari opened 7 months ago

alberto-scolari commented 7 months ago

Currently, the user has to manually modify include/graphblas/base/config.hpp to set the architecture parameters. Not only this is inconvenient, but it also leads to multiple issues:

  1. if we forget to do it and then run performance tests, either we report suboptimal results or we recall the mistake and must redo the tests (it happened to everybody, it caused everybody many lost hours)
  2. if you integrate ALP into another project as a dependency, you cannot have a full "out of the box" experience (i.e., the project downloads and deploys ALP automatically), because you have to manually edit that header (example below)

The solution is indeed to automatically detect architectural features of interest and automatically apply them. This should be done in two (independent) phases:

  1. during CMake configuration, to build tests and examples for the target CPU
  2. every time the grbcxx script is invoked to compile; this because the script can be invoked on a different micro-arch than the one used for the CMake configuration (e.g., because of a shared setup in a cluster)

@anyzelman


find_package(ALPGraphBLAS CONFIG) # look for ALP in ALPGraphBLAS_ROOT directory, if given
if(NOT ALPGraphBLAS_FOUND)
    include(FetchContent)
    # download ALP and deploy automatically
    FetchContent_Declare(ALPGraphBLAS
        GIT_REPOSITORY https://github.com/Algebraic-Programming/ALP.git
        GIT_TAG "develop"
        GIT_SHALLOW TRUE
    )
    # here you should modify the header (e.g., by applying a patch): cumbersome ...
    FetchContent_MakeAvailable(ALPGraphBLAS)
endif()