Skip to content

Commit f0ec7b2

Browse files
author
Damian Rouson
committed
Replacing individual prerequisites build scripts (buildgcc, buildcmake,...) with one general prerequisite script ('build'). Adding OpenCoarrays installation script (install.sh). Known issues: flex build fails on OS X due to a eported bug for which a candidate patch exists (http://sourceforge.net/p/flex/bugs/182/). Installation script works when all prerequisites are present and when one missing prerequisite is hardwired into the script. Next step: generalize the install script to detect any missing priorities, download, and build CMake.
Signed-off-by: Damian Rouson <[email protected]>
1 parent d4f054e commit f0ec7b2

File tree

13 files changed

+595
-1077
lines changed

13 files changed

+595
-1077
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ CHECK_Fortran_SOURCE_COMPILES("
6767
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
6868

6969
add_subdirectory(src)
70+
add_subdirectory(install_prerequisites)
7071

7172
install(EXPORT OpenCoarraysTargets
7273
NAMESPACE

INSTALL.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,40 @@ OpenCoarrays, install OpenCoarrays, build the tests, run the tests, and report t
124124

125125
tar xvzf opencoarrays.tar.gz
126126
cd opencoarrays
127+
<<<<<<< HEAD
127128
mkdir build
128129
cd build
130+
=======
131+
mkdir opencoarrays-build
132+
cd opencoarrays-build
133+
>>>>>>> a0474e8
129134
CC=mpicc FC=mpif90 cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}
130135
make
131136
make install
132137
ctest
133138

134139
where the the first part of the cmake line sets the CC and FC environment variables
135140
and the final part of the same line defines the installation path as the present
136-
working directory ("build"). Please report any test failures to via the OpenCoarrays
137-
[Issues] page.
141+
working directory ("opencoarrays-build"). Please report any test failures via the
142+
OpenCoarrays [Issues] page.
138143

139144
A complete installation should result in the creation of the following directories
140145
inside the installation path (.e.g, inside "build" in the above example):
141146

142-
* bin: contains the "caf" compiler wrapper and the "cafrun" launcher bash scripts
147+
* bin: contains the compiler wrapper (caf), program launcher (cafun), and prerequisites builder (build)
143148
* mod: contains the "opencoarrays.mod" module file for use with non-OpenCoarrays-aware compilers
144149
* lib: contains the "libcaf_mpi.a" static library to which codes link for CAF support
145150

146151
Advanced options (most users should not use these):
147152

148-
-DLEGACY_ARCHITECTURE=OFF enables the use of FFT libraries that employ AVX instructions
149-
-DHIGH_RESOLUTION_TIMER=ON enables timers that tick once per clock cycle
150-
-DCOMPILER_SUPPORTS_ATOMICS enables support for the proposed Fortran 2015 events feature
151-
-DUSE_EXTENSIONS builds the [opencoarrays] module for use with non-OpenCoarrays-aware compilers
153+
-DLEGACY_ARCHITECTURE=OFF enables the use of FFT libraries that employ AVX instructions
154+
-DHIGH_RESOLUTION_TIMER=ON enables timers that tick once per clock cycle
155+
-DCOMPILER_SUPPORTS_ATOMICS enables support for the proposed Fortran 2015 events feature
156+
-DUSE_EXTENSIONS builds the [opencoarrays] module for use with non-OpenCoarrays-aware compilers
157+
<<<<<<< HEAD
158+
-DCOMPILER_PROVIDES_MPI is set automatically when building with the Cray Compiler Environment
159+
=======
160+
>>>>>>> a0474e8
152161
153162
The first two flags above are not portable and the third enables code that is incomplete as
154163
of release 1.0.0. The fourth is set automatically by the CMake scripts based on the compiler

install.sh

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#!/bin/bash
2+
#
3+
# build
4+
#
5+
# -- This script installs OpenCoarrays and its prerequisites.
6+
#
7+
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8+
# Copyright (c) 2015, Sourcery, Inc.
9+
# Copyright (c) 2015, Sourcery Institute
10+
# All rights reserved.
11+
#
12+
# Redistribution and use in source and binary forms, with or without modification,
13+
# are permitted provided that the following conditions are met:
14+
#
15+
# 1. Redistributions of source code must retain the above copyright notice, this
16+
# list of conditions and the following disclaimer.
17+
# 2. Redistributions in binary form must reproduce the above copyright notice, this
18+
# list of conditions and the following disclaimer in the documentation and/or
19+
# other materials provided with the distribution.
20+
# 3. Neither the names of the copyright holders nor the names of their contributors
21+
# may be used to endorse or promote products derived from this software without
22+
# specific prior written permission.
23+
#
24+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
# POSSIBILITY OF SUCH DAMAGE.
34+
35+
this_script=`basename $0`
36+
37+
usage()
38+
{
39+
echo ""
40+
echo " $this_script - Bash script for installing OpenCoarrays and its prerequisites"
41+
echo ""
42+
echo " Usage (optional arguments in square brackets): "
43+
echo " $this_script [<options>] or [<installation-path> <number-of-threads>]"
44+
echo ""
45+
echo " Options:"
46+
echo " --help, -h Show this help message"
47+
echo ""
48+
echo " Examples:"
49+
echo ""
50+
echo " $this_script"
51+
echo " $this_script ${PWD}"
52+
echo " $this_script /opt/opencoarrays 4"
53+
echo " $this_script --help"
54+
echo ""
55+
exit 1
56+
}
57+
58+
# Interpret the first command-line argument, if present, as the installation path.
59+
# Otherwise, install in a subdirectory of the present working directory.
60+
default_install_path=${PWD}/opencoarrays-installation
61+
if [[ -z $1 ]]; then
62+
install_path=$default_install_path
63+
else
64+
install_path=$1
65+
fi
66+
67+
build_path=${PWD}/opencorrays-build
68+
69+
# Interpret the second command-line argument, if present, as the number of threads for 'make'.
70+
# Otherwise, default to single-threaded 'make'.
71+
if [ -z $2 ]; then
72+
num_threads=1
73+
else
74+
num_threads=$2
75+
fi
76+
77+
CC_DEFAULT=gcc
78+
FC_DEFAULT=gfortran
79+
MPICC_DEFAULT=mpicc
80+
MPIFC_DEFAULT=mpif90
81+
82+
printf "Checking whether CC and FC are both defined..."
83+
if [[ -z $CC || -z $FC ]]; then
84+
CC=$CC_DEFAULT
85+
FC=$FC_DEFAULT
86+
printf "no.\n"
87+
printf "Using default CC=$CC, FC=$FC\n"
88+
fi
89+
90+
printf "Checking whether MPICC and MPIFC are both defined..."
91+
if [[ -z $MPICC || -z $MPIF90 ]]; then
92+
MPICC=$MPICC_DEFAULT
93+
MPIFC=$MPIFC_DEFAULT
94+
printf "no.\n"
95+
printf "Using default MPICC=$MPICC, MPIFC=$MPIFC\n"
96+
fi
97+
98+
find_or_install()
99+
{
100+
package_to_check=$1
101+
printf "Checking whether $package_to_check is in the PATH... "
102+
if type $package_to_check > /dev/null; then
103+
printf "yes.\n"
104+
return
105+
fi
106+
# Set the MPI Fortran compiler for building OpenCoarrays prerequisites.
107+
if [ ! -z $MPIF90 ]; then
108+
109+
# MPIF90 environment variable is not empty
110+
printf "Environment variable MPIF90=$MPIF90.\n"
111+
if type $MPIF90 > /dev/null; then
112+
# MPIF90 environment variable specifies an executable program
113+
printf "Using MPIF90=$MPIF90 as the MPI Fortran compiler.\n"
114+
else
115+
# The specified MPIF90 was not found or does not execute. Time to bail.
116+
printf "MPIF90=$MPIF90 not found. Please set the MPIF90 environment variable to the \n"
117+
printf "name of an MPI Fortran compiler and prepend the path if it is not in your PATH.\n"
118+
exit 1
119+
fi
120+
121+
else # MPIF90 environment variable is empty
122+
123+
printf "Environment variable MPIF90 is empty. Trying mpif90'.\n"
124+
125+
if type $MPIF90_DEFAULT > /dev/null; then
126+
# mpif90 is an executable program in the user's PATH
127+
printf "Found mpif90 in your path. Using mpif90 as the MPI Fortran compiler.\n"
128+
MPIF90=$MPIF90_DEFAULT
129+
130+
else #
131+
printf "No $MPIF90_DEFAULT in your path. Ok to download and install the default MPI (MPICH)? (y/n).\n"
132+
read proceed
133+
if [[ $proceed == "y" ]]; then
134+
printf "Downloading, building, and installing MPICH.\n"
135+
cd install_prerequisites &&
136+
FC=$FC_DEFAULT CC=$CC_DEFAULT ./build mpich &&
137+
mpich_install_path=`./build mpich --default --query` &&
138+
if [[ -f "$mpich_install_path/bin/mpif90" ]]; then
139+
printf "Installed $MPI_F90 in $mpich_install_path (You might add the 'bin' subdirectory to your PATH).\n"
140+
else
141+
printf "Can't find mpif90 in the expected location: $mpich_install_path/bin/mpif90 \n"
142+
fi
143+
else
144+
printf "Please install an MPI Fortran compiler and restart $this_script.\n"
145+
exit 1
146+
fi
147+
fi
148+
149+
exit 1
150+
fi
151+
exit 1
152+
}
153+
154+
if [[ $1 == '--help' || $1 == '-h' ]]; then
155+
# Print usage information if script is invoked with --help or -h argument
156+
usage | less
157+
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
158+
# Print script copyright if invoked with -v, -V, or --version argument
159+
echo ""
160+
echo "OpenCoarrays installer"
161+
echo "Copyright (C) 2015 Sourcery, Inc."
162+
echo "Copyright (C) 2015 Sourcery Institute"
163+
echo ""
164+
echo "$this_script comes with NO WARRANTY, to the extent permitted by law."
165+
echo "You may redistribute copies of $this_script under the terms of the"
166+
echo "BSD 3-Clause License. For more information about these matters, see"
167+
echo "http://www.sourceryinstitute.org/license.html"
168+
echo ""
169+
else
170+
171+
# Find or install prerequisites and install OpenCoarrays
172+
installation_record=install-opencoarrays.log
173+
time \
174+
{
175+
find_or_install "cmake" &&
176+
find_or_install "$MPIFC" &&
177+
find_or_install "$MPICC" &&
178+
mkdir -p opencoarrays-build &&
179+
cd opencoarrays-build &&
180+
CC=$MPICC FC=$MPIFC cmake .. -DCMAKE_INSTALL_PREFIX=$install_path &&
181+
make &&
182+
make install
183+
} >&1 | tee $installation_record
184+
185+
# Report installation success or failure
186+
printf "\n"
187+
if [[ -f $install_path/bin/caf && -f $install_path/bin/cafrun && -f $install_path/bin/build ]]; then
188+
printf "$this_script: Done.\n"
189+
printf "The OpenCoarrays compiler wrapper (caf), program launcher (cafrun), and\n"
190+
printf "prerequisite package installer (build) are in the following directory:\n"
191+
printf "$install_path/bin.\n"
192+
else
193+
printf "Something went wrong. The OpenCoarrays compiler wrapper (caf),\n"
194+
printf "program launcher (cafrun), and prerequisite package installer (build) \n"
195+
printf "are not in the expected location:\n"
196+
printf "$install_path/bin.\n"
197+
printf "Please review the '$installation_record' file for more information.\n"
198+
fi
199+
fi

install_prerequisites/CMakeLists.txt

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
1-
# Write the script that builds GCC from source
1+
# Write the script that downloads, builds, and installs OpenCoarrays prerequisites from source
22
set(exe_dir ${CMAKE_BINARY_DIR}/bin_staging)
3-
set(gcc_build_script ${exe_dir}/buildgcc)
3+
set(build_script ${exe_dir}/build)
44
install(
5-
FILES "${gcc_build_script}"
5+
FILES "${build_script}"
66
PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
7-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
7+
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/
88
)
9-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buildgcc BUILDGCC_SCRIPT)
10-
file(WRITE "${gcc_build_script}" "${BUILDGCC_SCRIPT}\n")
11-
12-
# Write the script that builds MPICH from source
13-
set(mpich_build_script ${exe_dir}/buildmpich)
14-
install(
15-
FILES "${mpich_build_script}"
16-
PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
17-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
18-
)
19-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buildmpich BUILDMPICH_SCRIPT)
20-
file(WRITE "${mpich_build_script}" "${BUILDMPICH_SCRIPT}\n")
21-
22-
# Write the script that builds CMake from source
23-
set(cmake_build_script ${exe_dir}/buildcmake)
24-
install(
25-
FILES "${cmake_build_script}"
26-
PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
27-
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
28-
)
29-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/buildcmake BUILDCMAKE_SCRIPT)
30-
file(WRITE "${cmake_build_script}" "${BUILDCMAKE_SCRIPT}\n")
9+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/build BUILD_SCRIPT)
10+
file(WRITE "${build_script}" "${BUILD_SCRIPT}\n")

0 commit comments

Comments
 (0)