Skip to content

Commit

Permalink
CMake Cleanup (#142)
Browse files Browse the repository at this point in the history
* require cmake version 3.5
* Find MPI in CMake so that setting CC is no longer required.
* use CMAKE_SYSTEM_PROCESSOR instead of ARCH
* ppc64lc clock changes from @markplagge 159311a
* remove ARCH and CC from travis builds
  • Loading branch information
gonsie authored Mar 28, 2019
1 parent 497af49 commit 2a6cc8e
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 46 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ before_install:
- mpirun --version
script:
- mkdir cxx-build && cd cxx-build
- ARCH=x86_64 CC=mpicc cmake -DCMAKE_BUILD_TYPE=Release ..
- cmake -DCMAKE_BUILD_TYPE=Release ..
- export MPICH_CC=clang++
- make
- unset MPICH_CC
- cd ..
- mkdir release && cd release
- ARCH=x86_64 CC=mpicc MPICH_CC=clang cmake -DCMAKE_BUILD_TYPE=Release -DROSS_BUILD_MODELS=ON ..
- MPICH_CC=clang cmake -DCMAKE_BUILD_TYPE=Release -DROSS_BUILD_MODELS=ON ..
- make
- CTEST_OUTPUT_ON_FAILURE=1 make test
- cd ..
- mkdir build && cd build
- ARCH=x86_64 CC=mpicc MPICH_CC=clang cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DROSS_BUILD_MODELS=ON ..
- MPICH_CC=clang cmake -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DROSS_BUILD_MODELS=ON ..
- make
- CTEST_OUTPUT_ON_FAILURE=1 make test
- make coveralls
- cd ..
- mkdir build2 && cd build2
- ARCH=x86_64 CC=mpicc MPICH_CC=clang cmake -DAVL_TREE=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DROSS_BUILD_MODELS=ON ..
- MPICH_CC=clang cmake -DAVL_TREE=OFF -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug -DROSS_BUILD_MODELS=ON ..
- make
- CTEST_OUTPUT_ON_FAILURE=1 make test
- make coveralls
Expand All @@ -63,7 +63,7 @@ after_success:
- git clone -b master --single-branch https://github.com/ross-org/ROSS
- cd ROSS
- mkdir build && cd build
- ARCH=x86_64 cmake -DROSS_BUILD_DOXYGEN=ON -DDOXYGEN_CALLER_GRAPHS=ON -DDOXYGEN_CALL_GRAPHS=ON ..
- cmake -DROSS_BUILD_DOXYGEN=ON -DDOXYGEN_CALLER_GRAPHS=ON -DDOXYGEN_CALL_GRAPHS=ON ..
- make apidoc
- cd ../..
- git rm -r ROSS-docs
Expand Down
69 changes: 40 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROJECT(ROSS_TOP C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -44,75 +44,86 @@ SET(GVT mpi_allreduce)

# Architecture setting and management
SET(VALID_ARCH NO)
SET(ARCH $ENV{ARCH} CACHE STRING "Target architecture")
MARK_AS_ADVANCED(ARCH)
IF(NOT ARCH)
MESSAGE(FATAL_ERROR "ARCH not defined!\n"
"Please set ARCH to be one of (i386 | bgl | bgp | x86_64 | ppc64 | ppc64 | ppc64le)")
ENDIF(NOT ARCH)

IF(ARCH STREQUAL i386)

IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL i386)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall")
ADD_DEFINITIONS(-D_GNU_SOURCE)
SET(CLOCK i386)
ENDIF(ARCH STREQUAL i386)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL i386)

IF(ARCH STREQUAL bgl)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgl)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qflag=i:i -qattr=full -O5")
SET(OPTIONS "-qtune=440 -qarch=440d")
SET(CLOCK bgl)
ENDIF(ARCH STREQUAL bgl)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgl)

IF(ARCH STREQUAL bgp)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgp)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qflag=i:i -qattr=full -O5")
SET(OPTIONS "-qtune=450 -qarch=450d")
SET(CLOCK bgl)
ENDIF(ARCH STREQUAL bgp)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgp)

IF(ARCH STREQUAL bgq)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgq)
SET(VALID_ARCH YES)
OPTION(USE_BGPM "Blue Gene/Q specific Performance Counters" OFF)
SET(BGPM_INCLUDE /bgsys/drivers/ppcfloor/bgpm/include/)
ADD_LIBRARY(imp_bgpm STATIC IMPORTED)
SET_PROPERTY(TARGET imp_bgpm PROPERTY IMPORTED_LOCATION /bgsys/drivers/ppcfloor/bgpm/lib/libbgpm.a)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${BGPM_INCLUDE} -O5 -qstrict -qprefetch=aggressive -qarch=qp -qtune=qp -qmaxmem=-1 -qsimd=noauto -qreport -qhot")
SET(CLOCK bgq)
ENDIF(ARCH STREQUAL bgq)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL bgq)

IF(ARCH STREQUAL ppc64)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ppc64)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall")
ADD_DEFINITIONS(-D_GNU_SOURCE)
SET(CLOCK ppc)
ENDIF(ARCH STREQUAL ppc64)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ppc64)

IF(ARCH STREQUAL ppc64le)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ppc64le)
SET(VALID_ARCH YES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O5 -qprefetch=aggressive -qarch=pwr9 -qtune=auto -qmaxmem=-1 -qsimd=noauto -qhot")
SET(CLOCK ppc64le)
ENDIF(ARCH STREQUAL ppc64le)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ppc64le)

IF(ARCH STREQUAL x86_64)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
SET(VALID_ARCH YES)
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
ADD_DEFINITIONS(-D_GNU_SOURCE)
SET(CLOCK amd64)
ENDIF(ARCH STREQUAL x86_64)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)

IF(ARCH STREQUAL aarch64)
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)
SET(VALID_ARCH YES)
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
ADD_DEFINITIONS(-D_GNU_SOURCE)
SET(CLOCK aarch64)
ENDIF(ARCH STREQUAL aarch64)

IF(NOT VALID_ARCH)
MESSAGE(FATAL_ERROR "ARCH not valid!\n"
"Please set ARCH to be one of (i386 | bgl | bgp | x86_64 | ppc64 | ppc64le | aarch64)")
ENDIF(NOT VALID_ARCH)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL aarch64)


IF(VALID_ARCH)
MESSAGE(STATUS "System architecture detected: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "Using C_FLAGS: ${CMAKE_C_FLAGS}")
MESSAGE(STATUS "Using CLOCK: ${CLOCK}")
ELSE(VALID_ARCH)
MESSAGE(FATAL_ERROR "System architecture not recognized!\n"
"Found: ${CMAKE_SYSTEM_PROCESSOR}\n"
"Expected: i386 | x86_64 | ppc64 | ppc64le | aarch64")
ENDIF(VALID_ARCH)

## MPI
INCLUDE(SetupMPI)
IF(MPI_C_FOUND)
INCLUDE_DIRECTORIES(${MPI_C_INCLUDE_PATH})
LIST(APPEND ROSS_EXTERNAL_LIBS ${MPI_C_LIBRARIES})
ELSE(MPI_C_FOUND)
MESSAGE("WARNING: Could not find MPI!")
MESSAGE(" Either add an MPI compiler to your path (using modules)")
MESSAGE(" Or force CMake to build using the correct compiler (`export CC=mpicc`)")
ENDIF(MPI_C_FOUND)

# ROSS Core code
ADD_SUBDIRECTORY(core)
Expand Down
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ ADD_LIBRARY(ROSS_obj OBJECT ${ross_srcs})

ADD_LIBRARY(ROSS SHARED $<TARGET_OBJECTS:ROSS_obj>)
SET_TARGET_PROPERTIES(ROSS PROPERTIES OUTPUT_NAME ROSS)
TARGET_LINK_LIBRARIES(ROSS ${ROSS_EXTERNAL_LIBS})

ADD_LIBRARY(ROSS_static STATIC $<TARGET_OBJECTS:ROSS_obj>)
SET_TARGET_PROPERTIES(ROSS_static PROPERTIES OUTPUT_NAME ROSS)
TARGET_LINK_LIBRARIES(ROSS_static ${ROSS_EXTERNAL_LIBS})

if (COVERALLS)
set(COVERAGE_SRCS ${ross_srcs})
Expand Down
4 changes: 2 additions & 2 deletions core/clock/ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#ifndef __GNUC__
# error gcc asm extensions required
#endif
#ifndef __ppc__
#if !(defined __ppc__ || defined __PPC__)
# error only ppc platform supported
#endif

static tw_clock tw_clock_read(void)
tw_clock tw_clock_read(void)
{
unsigned long tbu;
unsigned long tb1;
Expand Down
22 changes: 12 additions & 10 deletions core/clock/ppc64le.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#include <ross.h>

// rest from default to 512MHz as that's the timebase for the POWER9 system.
extern unsigned long long g_tw_clock_rate = 512000000.0;
extern unsigned long long g_tw_clock_rate;

static const tw_optdef clock_opts [] =
{
TWOPT_GROUP("ROSS Timing"),
TWOPT_ULONGLONG("clock-rate", g_tw_clock_rate, "CPU Clock Rate"),
TWOPT_END()
TWOPT_GROUP("ROSS Timing"),
TWOPT_ULONGLONG("clock-rate", g_tw_clock_rate, "CPU Clock Rate"),
TWOPT_END()
};

const tw_optdef *tw_clock_setup(void)
{
return clock_opts;

// reset from default to 512MHz as that's the timebase for the POWER9 system.
g_tw_clock_rate = 512000000.0;
return clock_opts;
}

tw_clock tw_clock_read(void)
Expand All @@ -31,13 +33,13 @@ tw_clock tw_clock_read(void)
void
tw_clock_init(tw_pe * me)
{
me->clock_time = 0;
me->clock_offset = tw_clock_read();
me->clock_time = 0;
me->clock_offset = tw_clock_read();
}

tw_clock
tw_clock_now(tw_pe * me)
{
me->clock_time = tw_clock_read() - me->clock_offset;
return me->clock_time;
me->clock_time = tw_clock_read() - me->clock_offset;
return me->clock_time;
}
77 changes: 77 additions & 0 deletions core/cmake/SetupMPI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
# LLNL-CODE-725085
#
# All rights reserved.
#
# This file is part of BLT.
#
# For additional details, please also read BLT/LICENSE.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################

################################
# MPI
################################

find_package(MPI)
message(STATUS "MPI C Compile Flags: ${MPI_C_COMPILE_FLAGS}")
message(STATUS "MPI C Include Path: ${MPI_C_INCLUDE_PATH}")
message(STATUS "MPI C Link Flags: ${MPI_C_LINK_FLAGS}")
message(STATUS "MPI C Libraries: ${MPI_C_LIBRARIES}")

message(STATUS "MPI CXX Compile Flags: ${MPI_CXX_COMPILE_FLAGS}")
message(STATUS "MPI CXX Include Path: ${MPI_CXX_INCLUDE_PATH}")
message(STATUS "MPI CXX Link Flags: ${MPI_CXX_LINK_FLAGS}")
message(STATUS "MPI CXX Libraries: ${MPI_CXX_LIBRARIES}")

message(STATUS "MPI Executable: ${MPIEXEC}")
message(STATUS "MPI Num Proc Flag: ${MPIEXEC_NUMPROC_FLAG}")


if (ENABLE_FORTRAN)
# Determine if we should use fortran mpif.h header or fortran mpi module
find_path(mpif_path
NAMES "mpif.h"
PATHS ${MPI_Fortran_INCLUDE_PATH}
NO_DEFAULT_PATH
)

if(mpif_path)
set(MPI_Fortran_USE_MPIF ON CACHE PATH "")
message(STATUS "Using MPI Fortran header: mpif.h")
else()
set(MPI_Fortran_USE_MPIF OFF CACHE PATH "")
message(STATUS "Using MPI Fortran module: mpi.mod")
endif()
endif()

0 comments on commit 2a6cc8e

Please sign in to comment.