Skip to content

Commit

Permalink
merge dev work for b2
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralgen committed Sep 12, 2019
1 parent 01f4b64 commit ca19ebf
Show file tree
Hide file tree
Showing 333 changed files with 1,716 additions and 3,337 deletions.
63 changes: 57 additions & 6 deletions CMakeLists.txt
Expand Up @@ -14,6 +14,8 @@ project(SPIRAL
VERSION 8.1.0
DESCRIPTION "SPIRAL Project"
LANGUAGES C CXX)

set(PROJECT_VERSION_TAG "b2")

## Prevent building directly into the source tree
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" SPIRAL_COMPILE_INPLACE)
Expand All @@ -35,14 +37,9 @@ if (SPIRAL_COMPILE_INPLACE)
endif()
endif()

## Some .h in sys_conf folder; reference root dir as include dir for "sys_conf/xxx.h"
## set(SPIRAL_INC ${SPIRAL_SOURCE_DIR}) # should not need when no sys_conf library
set(SPIRAL_CONFIG_DIR ${SPIRAL_SOURCE_DIR}/config)
set(SPIRAL_GEN_INC ${SPIRAL_BINARY_DIR}/include/spiral)

## set(SYSCONF_LIB sys_conf) # remove sys_conf library
## message(STATUS "SYSCONF_LIB = ${SYSCONF_LIB}")

## set(CMAKE_C_STANDARD 99)

include_directories(${SPIRAL_GEN_INC})
Expand Down Expand Up @@ -85,7 +82,61 @@ configure_file (
${SPIRAL_SOURCE_DIR}/gap/src/machine_endian.h
)

include ("${SPIRAL_SOURCE_DIR}/config/CMakeIncludes/ScriptConfig.cmake")
if (WIN32)
configure_file (
${SPIRAL_CONFIG_DIR}/spiral.bat.in
${SPIRAL_BINARY_DIR}/gap/spiral.bat
)
configure_file (
${SPIRAL_CONFIG_DIR}/spiral_debug.bat.in
${SPIRAL_BINARY_DIR}/gap/spiral_debug.bat
)
configure_file (
${SPIRAL_CONFIG_DIR}/_spiral_win.g.in
${SPIRAL_BINARY_DIR}/gap/_spiral_win.g
)
else ()
configure_file (
${SPIRAL_CONFIG_DIR}/spiral.in
${SPIRAL_BINARY_DIR}/gap/spiral
)
configure_file (
${SPIRAL_CONFIG_DIR}/spirald.in
${SPIRAL_BINARY_DIR}/gap/spirald
)
configure_file (
${SPIRAL_CONFIG_DIR}/_spiral.g.in
${SPIRAL_BINARY_DIR}/gap/_spiral.g
)
endif ()

## Rule to install the script files when install target is built

if (WIN32)
set (SPIRAL_STARTUP_FILES
${SPIRAL_BINARY_DIR}/gap/spiral.bat
${SPIRAL_BINARY_DIR}/gap/spiral_debug.bat
${SPIRAL_BINARY_DIR}/gap/_spiral_win.g
)
else ()
set (SPIRAL_STARTUP_FILES
${SPIRAL_BINARY_DIR}/gap/spiral
${SPIRAL_BINARY_DIR}/gap/spirald
${SPIRAL_BINARY_DIR}/gap/_spiral.g
)
endif ()

install (FILES ${SPIRAL_STARTUP_FILES}
DESTINATION ${SPIRAL_SOURCE_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
)

add_subdirectory(gap)

## enable_testing()
add_subdirectory(tests) ## holds test scripts

enable_testing()

77 changes: 75 additions & 2 deletions README.md
@@ -1,7 +1,7 @@
SPIRAL
======

This is the source tree for SPIRAL. It builds and runs on both Windows and Linux.
This is the source tree for SPIRAL. It builds and runs on Windows, Linux, and macOS.

## Building SPIRAL
### Prerequisites
Expand All @@ -10,11 +10,18 @@ This is the source tree for SPIRAL. It builds and runs on both Windows and Linu

SPIRAL builds on Linux/Unix with **gcc** and **make**, on Windows it builds with **Visual Studio**.

For macOS SPIRAL requires version 10.14 (Mojave) or later of macOS, with a compatible version of **Xcode** and
and **Xcode Command Line Tools**.

#### CMake 3

Use the most recent version of CMake 3 available for your platform. You can download CMake from [cmake.org](http://cmake.org/download/).

### Building on Linux and Other Unix-Like Systems
#### Python 3

The SPIRAL Profiler requires **Python 3**, which you can get from [python.org](http://python.org/downloads/).

### Building on Linux, macOS, and Other Unix-Like Systems

From the top directory of the SPIRAL source tree:
```
Expand All @@ -28,6 +35,8 @@ Use the **spiral** script in the top directory to start SPIRAL. You can run it
it and run **spiral** from elsewhere. The actual executable is ```gap/bin/gap```, but it must be started
with the **spiral** script in order to intialize and run correctly.

NOTE: The **spiral** script is automatically created, with deaults appropriate to your environment, during the build process, at the *install* step.

#### Debug Version on Linux/Unix

To build a debug version of SPIRAL for use with **gdb**, from the top directory:
Expand Down Expand Up @@ -68,6 +77,70 @@ to your path and run the batch script as **spiral** from a command window or scr
To debug SPIRAL on Windows, build and install the Debug version, use **spiral_debug.bat** to start SPIRAL, then in Visual Studio use
**Debug->Attach to Process...** to connect the debugger to **gapd.exe**.

## Testing SPIRAL

SPIRAL is released with a suite of self-tests. The tests are automatically
configured and made available when **CMake** configures the installation.

### Runnning Tests on Linux/Unix

All tests can be run using **make test** from the `<build>` folder, as follows:
```
cd build
make test
```

The **CMake** test driver program, **ctest**, can be used to exercise control
over which tests are run. You can run a specific named test, tests matching a
specific type, or all tests using **ctest**. A couple of examples are shown
here (refer to the CMake/ctest documetation for a full explanation of all
options). The ` -L ` and ` -R ` options take a regular expression argument to
identify which tests to run. ` -L ` matches against a label associated to
each test, while ` -R ` matches against the name of the test.

```
cd build
ctest -R Simple-FFT # Run the test matching the name "Simple-FFT"
ctest -R [.]*FFT[.]* # Run all test(s) with "FFT" in the name
ctest -L smoke # Run all test(s) with label "smoke"
ctest # Run all tests
```

### Disabling Tests

It is possible to disable the setup of tests when configuring the installation
with **CMake**. There are four categories of tests: basic, FFT, Advanced, and
Search. Each category of test may be turned off by adding a define on the
cmake command line, as follows:
```
-DTESTS_RUN_BASIC=OFF # Turn off basic tests
-DTESTS_RUN_ADVANCED=OFF # Turn off Advanced tests
-DTESTS_RUN_FFT=OFF # Turn off FFT tests
-DTESTS_RUN_SEARCH=OFF # Turn off Search tests
```

### Runnning Tests on Windows

**make** is genarally not available on Windows, so we need to use **ctest** in
order to run the tests. For Windows **ctest** needs to be informed which
confiuration was built, using the ` -C <config> ` option; where ` <config> `
is typically ` Release ` or ` Debug `. Other than this caveat, tests are configured, run, or
inhibited exactly the same on Windows as Linux/Unix. For example:
```
cd build
ctest -C Release -R Simple-FFT # Run the test matching the name "Simple-FFT" on Release build
ctest -C Release -R [.]*FFT[.]* # Run all test(s) with "FFT" in the name on Release build
ctest -C Debug -L smoke # Run all test(s) with label "smoke" on Debug build
ctest -C Release # Run all tests on Release build
```

### Debugging Failed Tests

Should a test fail you can view the complete test inputs/outputs generated
during the test run. Beneath the `<build>` folder is a **Testing/Temporary**
folder where **ctest** logs all the generated information. The data for the
last test run is contained in the file **LastTest.log**.

Spiral Profiler
--------------

Expand Down
17 changes: 0 additions & 17 deletions _spiral.g

This file was deleted.

86 changes: 86 additions & 0 deletions config/CMakeIncludes/ScriptConfig.cmake
@@ -0,0 +1,86 @@
##
## SPIRAL License
##
## Copyright (c) 2018, Carnegie Mellon University
## All rights reserved.
##
## See LICENSE file for full information
##

cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})

## Determine various configuration properties to create necessary inputs for launch/batch scripts

string (COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "AMD64" INTEL_WIN)
string (COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "x86_64" INTEL_LINUX)
string (COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "armv7l" ARM_LINUX)


if (${INTEL_WIN} OR ${INTEL_LINUX})
## Intel architecture, SupportedCPU = Core_AVX
set (CPU_ARCH_TYPE "Core_AVX")
set (CPU_FREQUENCY 2195)
set (SPIRAL_MEMORY_POOL "2048m")
elseif (${ARM_LINUX})
## Raspberry Pi, SupportedCPU = armv7l
set (CPU_ARCH_TYPE "ARMV7L")
set (CPU_FREQUENCY 1500)
set (SPIRAL_MEMORY_POOL "1024m")
elseif (${CMAKE_HOST_APPLE})
## Apple ... MacBook
set (CPU_ARCH_TYPE "Core_AVX")
set (CPU_FREQUENCY 2195)
set (SPIRAL_MEMORY_POOL "2048m")
endif ()

if (WIN32)
## Windows ... now determine which C compiler we're using...
string (COMPARE EQUAL "${CMAKE_C_COMPILER_ID}" "Intel" ICC_COMPILER)
string (COMPARE EQUAL "${CMAKE_C_COMPILER_ID}" "GNU" GCC_COMPILER)
set(SPIRAL_OS_NAME "Windows8")
if (${ICC_COMPILER})
## Intel ICC compiler
set (USE_COMPILER_ICC "true")
set (USE_COMPILER_GCC "false")
set (PROFILER_TARGET "win-x64-icc")
elseif (${GNU_COMPILER})
## GNU C compiler
set (USE_COMPILER_ICC "false")
set (USE_COMPILER_GCC "true")
set (PROFILER_TARGET "win-x86-gcc")
else ()
## Default to Visual Studio
set (USE_COMPILER_ICC "false")
set (USE_COMPILER_GCC "false")
set (PROFILER_TARGET "win-x86-vcc")
endif ()

elseif (${ARM_LINUX})
## Raspberry Pi
## Use GDB as debugger, --args ==> arguments after program name are for debugged process
set (PROFILER_TARGET "linux-arm-gcc")
set (PROFILE_TARGET_ID "linux_arm_gcc")
set (SPIRAL_OS_NAME "ArmLinux")
set (SPIRAL_COMPILER_NAME "GnuC_ARM")
set (SPIRAL_DEBUGGER_NAME "gdb --args")

elseif (${CMAKE_HOST_APPLE})
## Apple ... MacBook
## Use LLDB as debugger, requires --arch, and "--" after program name to identify program arguments
set (PROFILER_TARGET "darwin-x86")
set (PROFILE_TARGET_ID "linux_x86_gcc")
set (SPIRAL_OS_NAME "Linux64")
set (SPIRAL_COMPILER_NAME "GnuC")
set (SPIRAL_DEBUGGER_NAME "lldb --arch x86_64")
set (SPIRAL_CMD_ARGS_FLAG "--")

elseif (${INTEL_WIN} OR ${INTEL_LINUX})
## Linux ...
## Use GDB as debugger, --args ==> arguments after program name are for debugged process
set (PROFILER_TARGET "linux-x86")
set (PROFILE_TARGET_ID "linux_x86_gcc")
set (SPIRAL_OS_NAME "Linux64")
set (SPIRAL_COMPILER_NAME "GnuC")
set (SPIRAL_DEBUGGER_NAME "gdb --args")

endif ()
45 changes: 45 additions & 0 deletions config/CMakeIncludes/TestDefines.cmake
@@ -0,0 +1,45 @@
##
## SPIRAL License
##
## Copyright (c) 2018, Carnegie Mellon University
## All rights reserved.
##
## See LICENSE file for full information
##

cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})

## include(FindUnixCommands)

## GAP shell script name
if (WIN32)
file (TO_NATIVE_PATH ${SPIRAL_SOURCE_DIR}/spiral.bat TEST_GAP_EXEC_NAME)
else ()
include(FindUnixCommands)
file (TO_NATIVE_PATH ${SPIRAL_SOURCE_DIR}/spiral TEST_GAP_EXEC_NAME )
endif ()

## Define a function to add a test target, given a test name. The assumption
## is that all targets are executed by invoking Spiral, redirecting input
## from a test file and waiting until its done. The test script source file
## is assumed to be in the [current] subdirectory (parameter subdir) and has
## the same name as the test, appended with ".g".

function (my_add_test_target testname subdir)
file (TO_NATIVE_PATH ${TESTS_SOURCE_DIR}/${subdir}/${testname}.g _scrpt)
if (BASH)
add_test (NAME ${testname}
COMMAND ${BASH} -c "${TEST_GAP_EXEC_NAME} < ${_scrpt}"
)
else ()
if (WIN32)
add_test (NAME ${testname}
COMMAND ${TEST_GAP_EXEC_NAME} < ${_scrpt}
)
else ()
message(FATAL_ERROR "Unknown shell command for ${CMAKE_HOST_SYSTEM_NAME}")
endif ()
endif ()

endfunction ()

20 changes: 20 additions & 0 deletions config/_spiral.g.in
@@ -0,0 +1,20 @@
# This file is generated by CMake and will be overwritten if you
# re-run make install

if not IsBound(LocalConfig) then
#Print("\nLoading spiral\n");
Load(spiral);
fi;

LoadPackage("arep");

LocalConfig.cpuinfo := CopyFields(SupportedCPUs.@CPU_ARCH_TYPE@, rec(
freq := @CPU_FREQUENCY@
));

LocalConfig.osinfo := SupportedOSs.@SPIRAL_OS_NAME@;

SpiralDefaults.profile := spiral.profiler.default_profiles.@PROFILE_TARGET_ID@;

LocalConfig.compilerinfo := SupportedCompilers.@SPIRAL_COMPILER_NAME@;

0 comments on commit ca19ebf

Please sign in to comment.