[open-coarrays] 21/80: upstream 1.6.2
Alastair McKinstry
mckinstry at moszumanska.debian.org
Wed Oct 25 13:45:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository open-coarrays.
commit 653779dc1de4813fb66f286abfcc799cfda2eb05
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Tue Jul 26 15:21:09 2016 +0100
upstream 1.6.2
---
Brewfile | 21 +
CMakeLists.txt | 32 +-
CONTRIBUTING.md | 2 +-
STATUS.md | 6 +-
install.sh | 33 +-
install.sh-usage | 3 +
.../build-functions/download_if_necessary.sh | 60 +-
.../set_or_print_default_version.sh | 9 +-
.../build-functions/set_or_print_downloader.sh | 83 +-
prerequisites/build-functions/set_or_print_url.sh | 48 +-
prerequisites/build.sh | 57 +-
prerequisites/build.sh-usage | 5 +-
prerequisites/install-binary.sh | 2 +-
prerequisites/install-functions/find_or_install.sh | 199 ++--
prerequisites/install-functions/print_header.sh | 18 +-
prerequisites/install-functions/report_results.sh | 26 +-
prerequisites/install-ofp.sh | 8 +-
prerequisites/use-case/parse_command_line.sh | 2 +-
prerequisites/use-case/set_common_switches.sh | 1 +
src/CMakeLists.txt | 2 +-
src/Makefile | 103 +-
src/armci/Makefile | 21 -
src/armci/armci.c | 1006 --------------------
src/extensions/caf-foot | 6 +-
src/make.inc | 6 -
src/mpi/CMakeLists.txt | 5 +
src/mpi/mpi_caf.c | 3 +-
src/tests/integration/CMakeLists.txt | 2 +-
.../pde_solvers/navier-stokes/CMakeLists.txt | 2 +-
src/tests/unit/simple/Makefile | 10 +-
src/tests/unit/sync/CMakeLists.txt | 16 +-
31 files changed, 423 insertions(+), 1374 deletions(-)
diff --git a/Brewfile b/Brewfile
new file mode 100644
index 0000000..c3610f4
--- /dev/null
+++ b/Brewfile
@@ -0,0 +1,21 @@
+# Brewfile to install OpenCoarrays prerequisites with [Homebrew] or [Linuxbrew].
+#
+# TL;DR: `brew tap homebrew/bundle && brew bundle` to install prerequisites
+#
+# Homebrew for Mac OS X can be installed via:
+# `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
+# Linux brew (lives in userland, no sudo required) can be installed with:
+# `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/linuxbrew/go/install)"`
+#
+# Once Homebrew/Linuxbrew is installed, execute the following commands to install the required prerequisites:
+# `brew tap homebrew/bundle && brew bundle`
+#
+# NOTE: Until Linuxbrew upgrades to GCC 6.1 or later, you will have to edit the `mpich` line to:
+# `brew 'mpich', args: ['cc=gcc-5', 'cxx=g++-5']`
+
+brew 'cmake'
+brew 'gcc'
+brew 'mpich', args: ['cc=gcc-6', 'cxx=g++-6']
+
+# [Homebrew]: http://brew.sh
+# [Linuxbrew]: http://linuxbrew.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab094fb..bd24194 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ set ( CMAKE_BUILD_TYPE "Release"
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
#Name project and specify source languages
-project(opencoarrays VERSION 1.6.0 LANGUAGES C Fortran)
+project(opencoarrays VERSION 1.6.2 LANGUAGES C Fortran)
#Print an error message on an attempt to build inside the source directory tree:
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
@@ -151,8 +151,30 @@ add_custom_target ( uninstall
enable_testing()
+# Determine if we're using Open MPI
+execute_process(COMMAND ${MPIEXEC} --version
+ OUTPUT_VARIABLE mpi_version_out)
+if (mpi_version_out MATCHES "[Oo]pen[ -][Mm][Pp][Ii]")
+ message( STATUS "OpenMPI detected")
+ set ( openmpi true )
+endif ()
+
+include( ProcessorCount )
+ProcessorCount(N)
function(add_mpi_test name num_mpi_proc path)
- set(test_parameters ${MPIEXEC_NUMPROC_FLAG} ${num_mpi_proc} )
+ if ( ((N LESS num_mpi_proc) OR (N EQUAL 0)) )
+ message(STATUS "Test ${name} is oversubscribed: ${num_mpi_proc} ranks requested with ${N} system processor available.")
+ if ( openmpi )
+ if ( N LESS 2 )
+ set( num_mpi_proc 2 )
+ set (test_parameters --oversubscribed)
+ else()
+ set ( num_mpi_proc ${N} )
+ endif()
+ message( STATUS "Open-MPI detected, over-riding oversubscribed test, ${name}, with ${num_mpi_proc} ranks." )
+ endif()
+ endif()
+ set(test_parameters ${test_parameters} ${MPIEXEC_NUMPROC_FLAG} ${num_mpi_proc} )
add_test(NAME ${name} COMMAND ${MPIEXEC} ${test_parameters} "${path}")
set_property(TEST ${name} PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
endfunction(add_mpi_test)
@@ -166,9 +188,7 @@ if(opencoarrays_aware_compiler)
add_mpi_test(register_rename_me 2 ${tests_root}/unit/init_register/register_rename_me)
add_mpi_test(register_rename_me_too 2 ${tests_root}/unit/init_register/register_rename_me_too)
add_mpi_test(allocate_as_barrier 2 ${tests_root}/unit/init_register/allocate_as_barrier)
- if (NOT ( APPLE AND ( DEFINED ENV{TRAVIS} ) ) )
- add_mpi_test(allocate_as_barrier_proc 2 ${tests_root}/unit/init_register/allocate_as_barrier_proc)
- endif ()
+ add_mpi_test(allocate_as_barrier_proc 32 ${tests_root}/unit/init_register/allocate_as_barrier_proc)
add_mpi_test(get_array 2 ${tests_root}/unit/send-get/get_array)
add_mpi_test(send_array 2 ${tests_root}/unit/send-get/send_array)
add_mpi_test(get_with_offset_1d 2 ${tests_root}/unit/send-get/get_with_offset_1d)
@@ -182,7 +202,7 @@ if(opencoarrays_aware_compiler)
add_mpi_test(syncimages 32 ${tests_root}/unit/sync/syncimages)
add_mpi_test(duplicate_syncimages 8 ${tests_root}/unit/sync/duplicate_syncimages)
add_mpi_test(co_reduce 4 ${tests_root}/unit/collectives/co_reduce_test)
-# add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
+ add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
# Integration tests verifying the use of libcaf_mpi in applications
add_mpi_test(hello_multiverse 2 ${tests_root}/integration/coarrayHelloWorld/hello_multiverse)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d4fc519..6be2668 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -101,7 +101,7 @@ This is the development branch, akin to GCC's `trunk`. Both of `devel` and `mast
[these guidelines]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[an open issue]: https://github.com/sourceryinstitute/opencoarrays/issues
[Create a branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
-[OpenCoarrays repo]: https://github.com/sourceryinstitute/opencoarrays#fork-destination-box
+[OpenCoarrays repo]: https://github.com/sourceryinstitute/opencoarrays/fork
[Pull Request]: https://help.github.com/articles/using-pull-requests/
[Fork]: https://help.github.com/articles/fork-a-repo/
[helping out]: #helping-out
diff --git a/STATUS.md b/STATUS.md
index 51e4b47..0946993 100644
--- a/STATUS.md
+++ b/STATUS.md
@@ -21,7 +21,6 @@ Download this file as a PDF document
* [libcaf_mpi]
* [libcaf_x]
* [libcaf_gasnet]
- * [libcaf_armci]
* [libcaf_single]
* [Known Issues](#known-issues)
* [Library Issues](#library-issues)
@@ -98,8 +97,6 @@ Library Status
is currently out-of-date but might exhibit higher performance than [MPI] on
platforms for which [GASNet] provides a tuned conduit. Contact the
[OpenCoarrays Google Group] for further information.
-<a name="libcaf-armci">
-* **libcaf_armci**</a> (Unsupported): developed for research purposes and evaluation.
<a name="libcaf-single">
* **libcaf_single**</a> (Unsupported): developed to mirror the like-named library that
is included in GNU Fortran to facilitate compiling single-image (sequential)
@@ -185,14 +182,13 @@ To-Do List
[libcaf_x]: #libcaf-x
[libcaf_gasnet]: #libcaf-gasnet
[libcaf_single]: #libcaf-single
- [libcaf_armci]: #libcaf-armci
[GNU (gfortran)]: #compiler-issues-gnu
[Cray (ftn)]: #compiler-issues-cray
[Intel (ifort)]: #compiler-issues-intel
[Numerical Algorithms Group (nagfor)]: #compiler-issues-nag
[Portland Group (pgfortran)]: #compiler-issues-pg
[IBM (xlf)]: #compiler-issues-ibm
- [forking the OpenCoarrays repository]: https://github.com/sourceryinstitute/opencoarrays/blob/master/STATUS.md#fork-destination-box
+ [forking the OpenCoarrays repository]: https://github.com/sourceryinstitute/opencoarrays/fork
[TS 18508]: http://isotc.iso.org/livelink/livelink?func=ll&objId=17181227&objAction=Open
[opencoarrays module]: ./src/extensions/opencoarrays.F90
diff --git a/install.sh b/install.sh
index c8bb2d2..1e2645c 100755
--- a/install.sh
+++ b/install.sh
@@ -113,7 +113,7 @@ trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, S
[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. "
# shellcheck disable=SC2154
-if [[ "${arg_v}" == "${__flag_present}" || "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D}}}}" ]]; then
+if [[ "${arg_v}" == "${__flag_present}" || "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D:-${arg_B}}}}}" ]]; then
print_debug_only=7
if [ "$(( LOG_LEVEL < print_debug_only ))" -ne 0 ]; then
debug "Supressing info and debug messages: one of {-l, -v, -P, -U, -V, -D} present."
@@ -121,14 +121,17 @@ if [[ "${arg_v}" == "${__flag_present}" || "${arg_l}" == "${__flag_present}" ||
fi
fi
-[ ! -z "${arg_D}" ] && [ ! -z "${arg_P:-${arg_U:-${arg_V}}}" ] &&
- emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 101]"
+[ ! -z "${arg_D}" ] && [ ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 101]"
-[ ! -z "${arg_P}" ] && [ ! -z "${arg_U:-${arg_V}}" ] &&
- emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 103]"
+[ ! -z "${arg_P}" ] && [ ! -z "${arg_U:-${arg_V:-${arg_B}}}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 102]"
-[ ! -z "${arg_U}" ] && [ ! -z "${arg_V}" ] &&
- emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 104]"
+[ ! -z "${arg_U}" ] && [ ! -z "${arg_V:-${arg_B}}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 103]"
+
+[ ! -z "${arg_V}" ] && [ ! -z "${arg_B}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 104]"
### Print bootstrapped magic variables to STDERR when LOG_LEVEL
### is at the default value (6) or above.
@@ -142,6 +145,8 @@ info "__os: ${__os}"
info "__usage: ${__usage}"
info "LOG_LEVEL: ${LOG_LEVEL}"
+info "-b (--install-branch): ${arg_b}"
+info "-B (--list-branches): ${arg_B}"
info "-c (--with-c): ${arg_c}"
info "-C (--with-cxx): ${arg_C}"
info "-d (--debug): ${arg_d}"
@@ -161,6 +166,7 @@ info "-P (--print-path): ${arg_P}"
info "-U (--print-url): ${arg_U}"
info "-v (--version): ${arg_v}"
info "-V (--print-version): ${arg_V}"
+info "-y (--yes-to-all): ${arg_y}"
}
# This file is organized into three sections:
# 1. Command-line argument and environment variable processing.
@@ -231,11 +237,10 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
# ________________________________ Start of the Main Body ___________________________________
-
if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
# Print script copyright if invoked with -v, -V, or --version argument
- cmake_project_line=$(grep project ${opencoarrays_src_dir}/CMakeLists.txt | grep VERSION)
+ cmake_project_line="$(grep project "${opencoarrays_src_dir}/CMakeLists.txt" | grep VERSION)"
text_after_version_keyword="${cmake_project_line##*VERSION}"
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
opencoarrays_version=$text_before_language_keyword
@@ -255,10 +260,11 @@ if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
echo "${opencoarrays_version//[[:space:]]/}"
fi
-elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}" || "${arg_l}" == "${__flag_present}" ]]; then
+elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}" || "${arg_l}" == "${__flag_present}" ]]; then
# Delegate to build.sh for the packages it builds
- build_arg=${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_p}}}}}
+ build_arg=${arg_B:-${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_p}}}}}}
+ [ ! -z "${arg_B}" ] && build_flag="-B"
[ ! -z "${arg_D}" ] && build_flag="-D"
[ ! -z "${arg_P}" ] && build_flag="-P"
[ ! -z "${arg_U}" ] && build_flag="-U"
@@ -284,7 +290,6 @@ elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}" || "${arg_l}" == "${__fla
fi
elif [[ "${arg_p:-}" == "opencoarrays" ]]; then
-
cd prerequisites || exit 1
installation_record=install-opencoarrays.log
@@ -305,8 +310,8 @@ elif [[ "${arg_p:-}" == "ofp" ]]; then
elif [[ ! -z "${arg_p:-}" ]]; then
info "Invoking build script with the following command:"
- info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${@:-}"
- "${opencoarrays_src_dir}"/prerequisites/build.sh ${@:-}
+ info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${*:-}"
+ "${opencoarrays_src_dir}"/prerequisites/build.sh "${@:-}"
fi
# ____________________________________ End of Main Body ____________________________________________
diff --git a/install.sh-usage b/install.sh-usage
index 785412a..1161b8f 100644
--- a/install.sh-usage
+++ b/install.sh-usage
@@ -1,3 +1,5 @@
+ -b --branch [arg] Install the specified repository development branch.
+ -B --list-branches [arg] List the available branches in the specified package's repository.
-c --with-c [arg] Use specified C compiler.
-C --with-cxx [arg] Use specified C++ compiler.
-d --debug Enable debug mode.
@@ -17,3 +19,4 @@
-U --print-url [arg] Print download location for specified package.
-v --version Print OpenCoarrays version number.
-V --print-version [arg] Print version number for specified package.
+ -y --yes-to-all Build non-interactively by assuming affirmative user responses.
diff --git a/prerequisites/build-functions/download_if_necessary.sh b/prerequisites/build-functions/download_if_necessary.sh
index 4ff4d1c..53e881f 100644
--- a/prerequisites/build-functions/download_if_necessary.sh
+++ b/prerequisites/build-functions/download_if_necessary.sh
@@ -1,3 +1,4 @@
+# shellcheck shell=bash disable=SC2148
# shellcheck source=./ftp-url.sh
source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp-url.sh"
# shellcheck source=./set_SUDO_if_needed_to_write_to_directory.sh
@@ -12,14 +13,18 @@ download_if_necessary()
if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]] ; then
info "Found '${url_tail}' in ${download_path}."
info "If it resulted from an incomplete download, building ${package_name} could fail."
- info "Would you like to proceed anyway? (Y/n)"
- read -r proceed
- if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
- info "n"
- info "Please remove $url_tail and restart the installation to to ensure a fresh download." 1>&2
- emergency "Aborting. [exit 80]"
+ if [[ "${arg_y}" == "${__flag_present}" ]]; then
+ info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
else
- info "y"
+ info "Would you like to proceed anyway? (Y/n)"
+ read -r proceed
+ if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
+ info "n"
+ info "Please remove $url_tail and restart the installation to to ensure a fresh download." 1>&2
+ emergency "Aborting. [exit 80]"
+ else
+ info "y"
+ fi
fi
elif ! type "${fetch}" &> /dev/null; then
# The download mechanism is missing
@@ -32,7 +37,7 @@ download_if_necessary()
else
# The download mechanism is in the path.
if [[ "${fetch}" == "svn" ]]; then
- if [[ ${version_to_build} == '--avail' || ${version_to_build} == '-a' ]]; then
+ if [[ "${arg_B:-}" == "gcc" ]]; then
args="ls"
else
args="checkout"
@@ -45,9 +50,9 @@ download_if_necessary()
args="clone"
elif [[ "${fetch}" == "curl" ]]; then
first_three_characters=$(echo "${package_url}" | cut -c1-3)
- if [[ "${first_three_characters}" == "ftp" ]]; then
+ if [[ "${first_three_characters}" == "ftp" ]]; then
args="-LO -u anonymous:"
- elif [[ "${first_three_characters}" == "htt" ]]; then
+ elif [[ "${first_three_characters}" == "htt" ]]; then
args="-LO"
else
emergency "download_if_necessary.sh: Unrecognized URL."
@@ -59,29 +64,30 @@ download_if_necessary()
else
package_source_directory="${package_name}-${version_to_build}"
fi
- info "Downloading ${package_name} ${version_to_build} to the following location:"
+ info "Downloading ${package_name} ${version_to_build-} to the following location:"
info "${download_path}/${package_source_directory}"
info "Download command: \"${fetch}\" ${args:-} ${package_url}"
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
pushd "${download_path}"
- "${fetch}" ${args:-} ${package_url}
+ # args should be an array. Then "${args[@]:-}" will prevent shellcheck from complaining
+ "${fetch}" ${args:-} "${package_url}"
popd
- if [[ "${version_to_build}" == '--avail' || "${version_to_build}" == '-a' ]]; then
- # In this case, args="ls" and the list of available versions has been printed so we can move on.
- exit 1
- fi
- if [[ "${fetch}" == "svn" ]]; then
- search_path="${download_path}/${version_to_build}"
- else
- search_path="${download_path}/${url_tail}"
- fi
- if [ -f "${search_path}" ] || [ -d "${search_path}" ]; then
- info "Download succeeded. The ${package_name} source is in the following location:"
- info "${search_path}"
+ if [[ ! -z "${arg_B:-}" ]]; then
+ return
else
- info "Download failed. The ${package_name} source is not in the following, expected location:"
- info "${search_path}"
- emergency "Aborting. [exit 110]"
+ if [[ "${fetch}" == "svn" ]]; then
+ search_path="${download_path}/${version_to_build}"
+ else
+ search_path="${download_path}/${url_tail}"
+ fi
+ if [[ -f "${search_path}" || -d "${search_path}" ]]; then
+ info "Download succeeded. The ${package_name} source is in the following location:"
+ info "${search_path}"
+ else
+ info "Download failed. The ${package_name} source is not in the following, expected location:"
+ info "${search_path}"
+ emergency "Aborting. [exit 110]"
+ fi
fi
fi
}
diff --git a/prerequisites/build-functions/set_or_print_default_version.sh b/prerequisites/build-functions/set_or_print_default_version.sh
index ccb0697..a168549 100644
--- a/prerequisites/build-functions/set_or_print_default_version.sh
+++ b/prerequisites/build-functions/set_or_print_default_version.sh
@@ -1,3 +1,4 @@
+# shellcheck shell=bash disable=SC2148
# If -p, -D, -P, or -U specifies a package, set default_version
# If -V specifies a package, print the default_version and exit with normal status
# If -l is present, list all packages and versions and exit with normal status
@@ -15,11 +16,11 @@ set_or_print_default_version()
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" # not needed for -l
if [[ "${package_name}" == "ofp" ]]; then
- ${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
+ "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
exit 0
- fi
+ fi
- [ "${package_name}" == "opencoarrays" ] &&
+ [ "${package_name}" == "opencoarrays" ] &&
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
@@ -57,6 +58,6 @@ set_or_print_default_version()
# Exit with error status and diagnostic output if empty default_version
if [[ -z "${default_version:-}" ]]; then
- emergency "Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names."
+ emergency "set_or_print_default.sh: Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names."
fi
}
diff --git a/prerequisites/build-functions/set_or_print_downloader.sh b/prerequisites/build-functions/set_or_print_downloader.sh
index 93f0847..fc6d8b8 100644
--- a/prerequisites/build-functions/set_or_print_downloader.sh
+++ b/prerequisites/build-functions/set_or_print_downloader.sh
@@ -1,3 +1,4 @@
+# shellcheck shell=bash disable=SC2148
# If -p, -P, -U, or -V specifies a package, set fetch variable
# If -D specifies a package, print "${fetch}" and exit with normal status
# If -l is present, list all packages and versions and exit with normal status
@@ -5,53 +6,53 @@
set_or_print_downloader()
{
# Verify requirements
- [ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}" ] &&
- emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
+ [ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
+
+ package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}"
- package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}"
if [[ "${package_name}" == "ofp" ]]; then
- ${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh "${@}"
+ "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
exit 0
fi
- if [[ $(uname) == "Darwin" ]]; then
- wget_or_curl=curl
- ftp_or_curl=curl
- else
- wget_or_curl=wget
- ftp_or_curl=ftp-url
- fi
- if [[ "${package_name}" == "gcc" && "${version_to_build}" != "trunk" ]]; then
- gcc_fetch="${ftp_or_curl}"
+
+ # Choose the first available download mechanism, prioritizing first any absolute requirement
+ # (svn for gcc development branches) and second robustness:
+ info "Checking available download mechanisms: ftp, wget, and curl."
+ info "\${package_name}=${package_name} \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"
+
+ if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then
+
+ if type svn &> /dev/null; then
+ fetch=svn
+ else
+ tried="svn"
+ fi
+
+ elif type curl &> /dev/null; then
+ fetch=curl
+ elif type wget &> /dev/null; then
+ fetch=wget
+ elif type ftp &> /dev/null; then
+ if [[ "${package_name}" == "gcc" || "${package_name}" == "wget" || "${package_name}" == "make" ||
+ "${package_name}" == "bison" || "${package_name}" == "m4" ]]; then
+ fetch=ftp-url
+ fi
else
- gcc_fetch="svn"
+ tried="curl, wget, and ftp"
fi
- # This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
- # denominator because, for licensing reasons, OS X only has bash 3 by default.)
- # See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
- package_fetch=(
- "gcc:${gcc_fetch}"
- "wget:${ftp_or_curl}"
- "cmake:${wget_or_curl}"
- "mpich:${wget_or_curl}"
- "flex:${wget_or_curl}"
- "bison:${ftp_or_curl}"
- "pkg-config:${wget_or_curl}"
- "make:${ftp_or_curl}"
- "m4:${ftp_or_curl}"
- "subversion:${wget_or_curl}"
- )
- for package in "${package_fetch[@]}" ; do
- KEY="${package%%:*}"
- VALUE="${package##*:}"
- if [[ "${package_name}" == "${KEY}" ]]; then
- # We recognize the package name so we set the download mechanism:
- fetch=${VALUE}
- # If a printout of the download mechanism was requested, then print it and exit with normal status
- [[ ! -z "${arg_D}" ]] && printf "%s\n" "${fetch}" && exit 0
- break # exit the for loop
- fi
- done
+
if [[ -z "${fetch:-}" ]]; then
- emergency "Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names."
+ if [[ -z "${arg_B:-}" ]]; then
+ warning "No available download mechanism. Options tried: ${tried}"
+ else
+ emergency "No available download mechanism. Option tried: ${tried}"
+ fi
+ fi
+
+ # If a printout of the download mechanism was requested, then print it and exit with normal status
+ if [[ ! -z "${arg_D}" ]]; then
+ printf "%s\n" "${fetch}"
+ exit 0
fi
}
diff --git a/prerequisites/build-functions/set_or_print_url.sh b/prerequisites/build-functions/set_or_print_url.sh
index 6fecd9e..ffe68ef 100644
--- a/prerequisites/build-functions/set_or_print_url.sh
+++ b/prerequisites/build-functions/set_or_print_url.sh
@@ -4,25 +4,27 @@
set_or_print_url()
{
# Verify requirements
- [ ! -z "${arg_U}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_V}}}}" ] &&
- emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
+ [ ! -z "${arg_U}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_V:-${arg_B}}}}}" ] &&
+ emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
# Get package name from argument passed with -p, -D, -P, -V, or -U
- package_to_build="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}"
+ package_to_build="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}"
if [[ "${package_to_build}" == 'cmake' ]]; then
major_minor="${version_to_build%.*}"
- elif [[ "${package_to_build}" == "gcc" && "${version_to_build}" != "trunk" ]]; then
- gcc_url_head="ftp.gnu.org:/gnu/gcc/gcc-${version_to_build}/"
- else
- gcc_url_head="svn://gcc.gnu.org/svn/gcc/"
+ elif [[ "${package_to_build}" == "gcc" ]]; then
+ if [[ -z "${arg_b:-${arg_B}}" ]]; then
+ gcc_url_head="ftp.gnu.org:/gnu/gcc/gcc-${version_to_build}/"
+ else
+ gcc_url_head="svn://gcc.gnu.org/svn/gcc/"
+ fi
fi
package_url_head=(
- "gcc;${gcc_url_head:-}"
+ "gcc;${gcc_url_head-}"
"wget;ftp.gnu.org:/gnu/wget/"
"m4;ftp.gnu.org:/gnu/m4/"
"pkg-config;http://pkgconfig.freedesktop.org/releases/"
- "mpich;http://www.mpich.org/static/downloads/${version_to_build}/"
+ "mpich;http://www.mpich.org/static/downloads/${version_to_build-}/"
"flex;http://sourceforge.net/projects/flex/files/"
"make;ftp://ftp.gnu.org/gnu/make/"
"bison;ftp.gnu.org:/gnu/bison/"
@@ -32,6 +34,8 @@ set_or_print_url()
for package in "${package_url_head[@]}" ; do
KEY="${package%%;*}"
VALUE="${package##*;}"
+ info "KEY=${KEY} VALUE=${VALUE}"
+
if [[ "${package_to_build}" == "${KEY}" ]]; then
# We recognize the package name so we set the URL head:
url_head="${VALUE}"
@@ -39,27 +43,25 @@ set_or_print_url()
fi
done
- # Set differing tails for GCC trunk versus branches
+ # Set differing tails for GCC release downloads versus development branch checkouts
if [[ "${package_to_build}" == 'gcc' ]]; then
if [[ "${fetch}" == 'svn' ]]; then
- gcc_tail="${version_to_build}"
- elif [[ "${version_to_build}" == '--avail' || "${version_to_build}" == '-a' ]]; then
- gcc_tail='branches'
+ gcc_tail=${version_to_build-branches}
else
gcc_tail="gcc-${version_to_build}.tar.bz2"
fi
fi
package_url_tail=(
- "gcc;${gcc_tail:-}"
- "wget;wget-${version_to_build}.tar.gz"
- "m4;m4-${version_to_build}.tar.bz2"
- "pkg-config;pkg-config-${version_to_build}.tar.gz"
- "mpich;mpich-${version_to_build}.tar.gz"
- "flex;flex-${version_to_build}.tar.bz2"
- "bison;bison-${version_to_build}.tar.gz"
- "make;make-${version_to_build}.tar.bz2"
- "cmake;cmake-${version_to_build}.tar.gz"
- "subversion;subversion-${version_to_build}.tar.gz"
+ "gcc;${gcc_tail-}"
+ "wget;wget-${version_to_build-}.tar.gz"
+ "m4;m4-${version_to_build-}.tar.bz2"
+ "pkg-config;pkg-config-${version_to_build-}.tar.gz"
+ "mpich;mpich-${version_to_build-}.tar.gz"
+ "flex;flex-${version_to_build-}.tar.bz2"
+ "bison;bison-${version_to_build-}.tar.gz"
+ "make;make-${version_to_build-}.tar.bz2"
+ "cmake;cmake-${version_to_build-}.tar.gz"
+ "subversion;subversion-${version_to_build-}.tar.gz"
)
for package in "${package_url_tail[@]}" ; do
KEY="${package%%;*}"
diff --git a/prerequisites/build.sh b/prerequisites/build.sh
index e3e8906..666071a 100755
--- a/prerequisites/build.sh
+++ b/prerequisites/build.sh
@@ -46,8 +46,6 @@ fi
# shellcheck source=./use-case/bootstrap.sh
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
-
-
# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if
# not needed. Other signals can be trapped too, like SIGINT and SIGTERM.
function cleanup_before_exit () {
@@ -61,14 +59,15 @@ trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, S
export __flag_present=1
# shellcheck disable=SC2154
-if [[ "${arg_l}" != "${__flag_present}" && "${arg_L}" != "${__flag_present}" &&
- "${arg_v}" != "${__flag_present}" && "${arg_h}" != "${__flag_present}" &&
- -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ]]; then
- help "${__base}: Insufficient arguments. Please pass either -D, -h, -l, -L, -p, -P, -U, -v, -V, or a longer equivalent."
+if [[ "${arg_l}" != "${__flag_present}" &&
+ "${arg_v}" != "${__flag_present}" &&
+ "${arg_h}" != "${__flag_present}" &&
+ -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}}" ]]; then
+ help "${__base}: Insufficient arguments. Please pass either -B, -D, -h, -l, -L, -p, -P, -U, -v, -V, or a longer equivalent."
fi
-# Suppress info and debug messages if -l, -P, -U, -V, -D, or their longer equivalent is present:
-[[ "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D}}}}" ]] && suppress_info_debug_messages
+# Suppress info and debug messages if -B, -l, -P, -U, -V, -D, or their longer equivalent is present:
+ [[ "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D:-${arg_B}}}}}" ]] && suppress_info_debug_messages
[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. "
@@ -90,6 +89,7 @@ info "__usage: ${__usage}"
info "LOG_LEVEL: ${LOG_LEVEL}"
info "-b (--branch): ${arg_b} "
+info "-B (--list-branches): ${arg_B} "
info "-c (--with-c): ${arg_c} "
info "-C (--with-cxx): ${arg_C} "
info "-d (--debug): ${arg_d} "
@@ -101,7 +101,6 @@ info "-i (--install-prefix): ${arg_i} "
info "-j (--num-threads): ${arg_j} "
info "-I (--install-version): ${arg_I} "
info "-l (--list-packages): ${arg_l} "
-info "-L (--list-branches): ${arg_L} "
info "-m (--with-cmake): ${arg_m} "
info "-M (--with-mpi): ${arg_M} "
info "-n (--no-color): ${arg_n} "
@@ -111,16 +110,21 @@ info "-t (--with-tau): ${arg_t} "
info "-U (--print-url): ${arg_U} "
info "-v (--version): ${arg_v} "
info "-V (--print-version): ${arg_V} "
+info "-y (--yes-to-all): ${arg_y} "
}
-# shellcheck source=./build-functions/set_or_print_default_version.sh
-source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
-set_or_print_default_version "${@}"
-export version_to_build="${arg_I:-${default_version}}"
+if [[ -z "${arg_B}" ]]; then
+ # shellcheck source=./build-functions/set_or_print_default_version.sh
+ source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh"
+ # shellcheck disable=SC2119
+ set_or_print_default_version
+ export version_to_build="${arg_I:-${arg_b:-${default_version}}}"
+fi
# shellcheck source=./build-functions/set_or_print_downloader.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh"
-set_or_print_downloader "${@}"
+# shellcheck disable=SC2119
+set_or_print_downloader
# shellcheck source=./build-functions/set_or_print_url.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_url.sh"
@@ -128,20 +132,25 @@ set_or_print_url
# shellcheck source=./build-functions/set_or_print_installation_path.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_installation_path.sh"
-set_or_print_installation_path
+
+if [[ -z "${arg_B}" ]]; then
+ set_or_print_installation_path
+fi
# shellcheck source=./build-functions/download_if_necessary.sh
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/download_if_necessary.sh"
download_if_necessary
-# shellcheck source=./build-functions/unpack_if_necessary.sh
-source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh"
-unpack_if_necessary
+if [[ -z "${arg_B}" ]]; then
+ # shellcheck source=./build-functions/unpack_if_necessary.sh
+ source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh"
+ unpack_if_necessary
-# shellcheck source=./build-functions/set_compilers.sh
-source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh"
-set_compilers
+ # shellcheck source=./build-functions/set_compilers.sh
+ source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh"
+ set_compilers
-# shellcheck source=./build-functions/build_and_install.sh
-source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh"
-build_and_install
+ # shellcheck source=./build-functions/build_and_install.sh
+ source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh"
+ build_and_install
+fi
diff --git a/prerequisites/build.sh-usage b/prerequisites/build.sh-usage
index a7533f3..0ac2287 100644
--- a/prerequisites/build.sh-usage
+++ b/prerequisites/build.sh-usage
@@ -1,4 +1,5 @@
- -b --branch [arg] Repository branch to download. Default="trunk"
+ -b --install-branch [arg] Install the specified repository development branch.
+ -B --list-branches [arg] List the available branches in the specified package's repository.
-c --with-c [arg] Use the specified C compiler. Default="gcc"
-C --with-cxx [arg] Use the specified C++ compiler. Default="g++"
-d --debug Enable debug mode.
@@ -10,7 +11,6 @@
-j --num-threads [arg] Number of threads to use when invoking make. Default="1"
-I --install-version [arg] Package version to install. (To see default, use -V or --print-version)
-l --list-packages List the packages this script can install.
- -L --list-branches List the repository branches this script can download.
-m --with-cmake [arg] Use the specified CMake installation. Default="cmake"
-M --with-mpi [arg] Use the specified MPI installation.
-n --no-color Disable color output.
@@ -21,3 +21,4 @@
-U --print-url [arg] Print URL for package specified in argument.
-v --version Print OpenCoarrays version number.
-V --print-version [arg] Print installation version for package specified in argument.
+ -y --yes-to-all Build non-interactively by assuming affirmative user responses.
diff --git a/prerequisites/install-binary.sh b/prerequisites/install-binary.sh
index c9939fb..6a9f811 100755
--- a/prerequisites/install-binary.sh
+++ b/prerequisites/install-binary.sh
@@ -44,7 +44,7 @@ if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
exit 2
else
- # shellcheck source=./prerequisites/use-case/bootstrap.sh
+ # shellcheck source=./use-case/bootstrap.sh
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
fi
### End of boilerplate -- start user edits below #########################
diff --git a/prerequisites/install-functions/find_or_install.sh b/prerequisites/install-functions/find_or_install.sh
index 98aa058..4e0734e 100644
--- a/prerequisites/install-functions/find_or_install.sh
+++ b/prerequisites/install-functions/find_or_install.sh
@@ -1,4 +1,4 @@
-# shellcheck disable=SC2154,SC2034
+# shellcheck shell=bash disable=SC2154,SC2034,SC2148
find_or_install()
{
package="$1"
@@ -28,9 +28,9 @@ find_or_install()
done
if [[ "$package" == "$executable" ]]; then
- printf "$this_script: Checking whether $executable is in the PATH..."
+ printf "%s: Checking whether %s is in the PATH..." "$this_script" "$executable"
else
- printf "$this_script: Checking whether $package executable $executable is in the PATH..."
+ printf "%s: Checking whether %s executable $executable is in the PATH..." "$this_script" "$package"
fi
if type "$executable" >& /dev/null; then
printf "yes.\n"
@@ -43,7 +43,7 @@ find_or_install()
package_install_path=$(./build.sh -P "$package")
- printf "Checking whether $executable is in $package_install_path..."
+ printf "Checking whether %s is in %s..." "$executable" "$package_install_path"
if [[ -x "$package_install_path/bin/$executable" ]]; then
printf "yes.\n"
script_installed_package=true
@@ -110,7 +110,7 @@ find_or_install()
# Every branch that discovers an acceptable pre-existing installation must set the
# MPIFC, MPICC, and MPICXX environment variables. Every branch must also manage the
# dependency stack.
-
+
# If the user specified a Fortran compiler, verify that mpif90 wraps the specified compiler
if [[ ! -z "${arg_M:-}" ]]; then
@@ -123,16 +123,6 @@ find_or_install()
stack_push dependency_exe "none"
stack_push dependency_path "none"
- if [[ ! -z "${arg_f:-}" ]]; then
- # -f or --with-fortran argument specifies a compiler, which we use if mpif90
- # invokes the specified compiler. Otherwise, we halt and print an error message.
- MPIFC_wraps=$(${MPIFC} --version)
- compiler=$(${arg_f} --version)
- if [[ "${MPIFC_wraps}" != "${compiler}" ]]; then
- emergency "Specified MPI ${MPIFC_wraps} wraps a compiler other than the specified Fortran compiler ${compiler}"
- fi
- fi
-
elif [[ "$script_installed_package" == true ]]; then
echo -e "$this_script: Using the $package installed by $this_script\n"
@@ -159,13 +149,13 @@ find_or_install()
printf "yes.\n"
if [[ ! -z "${arg_f:-}" ]]; then
-
+
info "-f (or --with-fortran) argument detected with value ${arg_f}"
- printf "yes.\n $this_script: Using the specified $executable.\n"
+ printf "yes.\n %s: Using the specified %s.\n" "$this_script" "$executable"
export MPIFC=mpif90
export MPICC=mpicc
export MPICXX=mpicxx
-
+
# Halt the recursion
stack_push dependency_pkg "none"
stack_push dependency_exe "none"
@@ -173,19 +163,19 @@ find_or_install()
else
- echo -e "$this_script: Checking whether $executable in PATH wraps gfortran version `./build.sh -V gcc` or later... "
+ echo -e "$this_script: Checking whether $executable in PATH wraps gfortran version $(./build.sh -V gcc) or later... "
$executable acceptable_compiler.f90 -o acceptable_compiler
$executable print_true.f90 -o print_true
acceptable=$(./acceptable_compiler)
is_true=$(./print_true)
rm acceptable_compiler print_true
-
+
if [[ "$acceptable" == "$is_true" ]]; then
- printf "yes.\n $this_script: Using the $executable found in the PATH.\n"
+ printf "yes.\n %s: Using the $executable found in the PATH.\n" "$this_script"
export MPIFC=mpif90
export MPICC=mpicc
export MPICXX=mpicxx
-
+
# Halt the recursion
stack_push dependency_pkg "none"
stack_push dependency_exe "none"
@@ -207,6 +197,15 @@ find_or_install()
stack_push dependency_path "none" "$(./build.sh -P "$package")" "$(./build.sh -P gcc)"
fi
+ # Check consistency of MPIFC, if set, and user-specified Fortran compiler
+ if [[ ! -z ${MPIFC:-} && ! -z "${arg_f:-}" ]]; then
+ MPIFC_wraps=$(${MPIFC} --version)
+ compiler=$(${arg_f} --version)
+ if [[ "${MPIFC_wraps}" != "${compiler}" ]]; then
+ emergency "Specified MPI ${MPIFC_wraps} wraps a compiler other than the specified Fortran compiler ${compiler}"
+ fi
+ fi
+
elif [[ $package == "gcc" ]]; then
# We arrive here when the 'elif [[ $package == "mpich" ]]' block pushes "gcc" onto the
@@ -261,7 +260,7 @@ find_or_install()
stack_push dependency_path "none"
elif [[ "$package_in_path" == "true" ]]; then
- echo -e "$this_script: Checking whether $executable in PATH is version `./build.sh -V gcc` or later..."
+ echo -e "$this_script: Checking whether $executable in PATH is version $(./build.sh -V gcc) or later..."
$executable -o acceptable_compiler acceptable_compiler.f90
$executable -o print_true print_true.f90
is_true=$(./print_true)
@@ -526,89 +525,93 @@ find_or_install()
echo "$this_script: Ready to install $package executable $executable in $package_install_path"
fi
- echo -e "$this_script: Ok to download (if necessary), build, and install $package from source? (Y/n) "
- read -r proceed_with_build
-
- if [[ "$proceed_with_build" == "n" || "$proceed_with_build" == "no" ]]; then
- printf "n\n"
- echo -e "$this_script: OpenCoarrays installation requires $package. Aborting. [exit 70]\n"
- exit 70
-
- else # permission granted to build
- printf "Y\n"
-
- # On OS X, CMake must be built with Apple LLVM gcc, which XCode command-line tools puts in /usr/bin
- if [[ $(uname) == "Darwin" && $package == "cmake" ]]; then
- if [[ -x "/usr/bin/gcc" ]]; then
- CC=/usr/bin/gcc
- else
- echo -e "$this_script: OS X detected. Please install XCode command-line tools and \n"
- echo -e "$this_script: ensure that /usr/bin/gcc exists and is executable. Aborting. [exit 75]\n"
- exit 75
- fi
- # Otherwise, if no CC has been defined yet, use the gcc in the user's PATH
- elif [[ -z "${CC:-}" ]]; then
- CC=gcc
+ if [[ "${arg_y}" == "${__flag_present}" ]]; then
+ info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
+ else
+ echo -e "$this_script: Ok to download (if necessary), build, and install $package from source? (Y/n) "
+ read -r proceed_with_build
+
+ if [[ "$proceed_with_build" == "n" || "$proceed_with_build" == "no" ]]; then
+ printf "n\n"
+ echo -e "$this_script: OpenCoarrays installation requires $package. Aborting. [exit 70]\n"
+ exit 70
+ else # permission granted to build
+ printf "Y\n"
fi
+ fi
- # On OS X, CMake must be built with Apple LLVM g++, which XCode command-line tools puts in /usr/bin
- if [[ $(uname) == "Darwin" && $package == "cmake" ]]; then
- if [[ -x "/usr/bin/g++" ]]; then
- CXX=/usr/bin/g++
- else
- echo -e "$this_script: OS X detected. Please install XCode command-line tools \n"
- echo -e "$this_script: and ensure that /usr/bin/g++ exists and is executable. Aborting. [exit 76]\n"
- exit 76
- fi
- # Otherwise, if no CXX has been defined yet, use the g++ in the user's PATH
- elif [[ -z "${CXX:-}" ]]; then
- CXX=g++
+ # On OS X, CMake must be built with Apple LLVM gcc, which XCode command-line tools puts in /usr/bin
+ if [[ $(uname) == "Darwin" && $package == "cmake" ]]; then
+ if [[ -x "/usr/bin/gcc" ]]; then
+ CC=/usr/bin/gcc
+ else
+ echo -e "$this_script: OS X detected. Please install XCode command-line tools and \n"
+ echo -e "$this_script: ensure that /usr/bin/gcc exists and is executable. Aborting. [exit 75]\n"
+ exit 75
fi
+ # Otherwise, if no CC has been defined yet, use the gcc in the user's PATH
+ elif [[ -z "${CC:-}" ]]; then
+ CC=gcc
+ fi
- # If no FC has been defined yet, use the gfortran in the user's PATH
- if [[ -z "${FC:-}" ]]; then
- FC=gfortran
+ # On OS X, CMake must be built with Apple LLVM g++, which XCode command-line tools puts in /usr/bin
+ if [[ $(uname) == "Darwin" && $package == "cmake" ]]; then
+ if [[ -x "/usr/bin/g++" ]]; then
+ CXX=/usr/bin/g++
+ else
+ echo -e "$this_script: OS X detected. Please install XCode command-line tools \n"
+ echo -e "$this_script: and ensure that /usr/bin/g++ exists and is executable. Aborting. [exit 76]\n"
+ exit 76
fi
+ # Otherwise, if no CXX has been defined yet, use the g++ in the user's PATH
+ elif [[ -z "${CXX:-}" ]]; then
+ CXX=g++
+ fi
+ # If no FC has been defined yet, use the gfortran in the user's PATH
+ if [[ -z "${FC:-}" ]]; then
+ FC=gfortran
+ fi
- # Strip trailing package name and version number, if present, from installation path
- default_package_version=$(./build.sh -V ${package})
- package_install_prefix="${package_install_path%${package}/${arg_I:-${default_package_version}}*}"
- echo -e "$this_script: Downloading, building, and installing $package \n"
- echo "$this_script: Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads"
- FC="$FC" CC="$CC" CXX="$CXX" ./build.sh -p "$package" -i "$package_install_prefix" -j "$num_threads"
+ # Strip trailing package name and version number, if present, from installation path
+ default_package_version=$(./build.sh -V "${package}")
+ package_install_prefix="${package_install_path%${package}/${arg_I:-${default_package_version}}*}"
- if [[ -x "$package_install_path/bin/$executable" ]]; then
- echo -e "$this_script: Installation successful.\n"
- if [[ "$package" == "$executable" ]]; then
- echo -e "$this_script: $executable is in $package_install_path/bin \n"
- else
- echo -e "$this_script: $package executable $executable is in $package_install_path/bin \n"
- fi
- # TODO Merge all applicable branches under one 'if [[ $package == $executable ]]; then'
- if [[ $package == "cmake" ]]; then
- echo "$this_script: export CMAKE=$package_install_path/bin/$executable"
- export CMAKE="$package_install_path/bin/$executable"
- elif [[ $package == "bison" ]]; then
- echo "$this_script: export YACC=$package_install_path/bin/$executable"
- export YACC="$package_install_path/bin/$executable"
- elif [[ $package == "flex" ]]; then
- echo "$this_script: export FLEX=$package_install_path/bin/$executable"
- export FLEX="$package_install_path/bin/$executable"
- elif [[ $package == "m4" ]]; then
- echo "$this_script: export M4=$package_install_path/bin/$executable"
- export M4="$package_install_path/bin/$executable"
- elif [[ $package == "gcc" ]]; then
- echo "$this_script: export FC=$package_install_path/bin/gfortran"
- export FC="$package_install_path/bin/gfortran"
- echo "$this_script: export CC=$package_install_path/bin/gcc"
- export CC="$package_install_path/bin/gcc"
- echo "$this_script: export CXX=$package_install_path/bin/g++"
- export CXX="$package_install_path/bin/g++"
- gfortran_lib_paths="$package_install_path/lib64/:$package_install_path/lib"
- if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then
- export LD_LIBRARY_PATH="$gfortran_lib_paths"
+ echo -e "$this_script: Downloading, building, and installing $package \n"
+ echo "$this_script: Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads"
+ FC="$FC" CC="$CC" CXX="$CXX" ./build.sh -p "$package" -i "$package_install_prefix" -j "$num_threads"
+
+ if [[ -x "$package_install_path/bin/$executable" ]]; then
+ echo -e "$this_script: Installation successful.\n"
+ if [[ "$package" == "$executable" ]]; then
+ echo -e "$this_script: $executable is in $package_install_path/bin \n"
+ else
+ echo -e "$this_script: $package executable $executable is in $package_install_path/bin \n"
+ fi
+ # TODO Merge all applicable branches under one 'if [[ $package == $executable ]]; then'
+ if [[ $package == "cmake" ]]; then
+ echo "$this_script: export CMAKE=$package_install_path/bin/$executable"
+ export CMAKE="$package_install_path/bin/$executable"
+ elif [[ $package == "bison" ]]; then
+ echo "$this_script: export YACC=$package_install_path/bin/$executable"
+ export YACC="$package_install_path/bin/$executable"
+ elif [[ $package == "flex" ]]; then
+ echo "$this_script: export FLEX=$package_install_path/bin/$executable"
+ export FLEX="$package_install_path/bin/$executable"
+ elif [[ $package == "m4" ]]; then
+ echo "$this_script: export M4=$package_install_path/bin/$executable"
+ export M4="$package_install_path/bin/$executable"
+ elif [[ $package == "gcc" ]]; then
+ echo "$this_script: export FC=$package_install_path/bin/gfortran"
+ export FC="$package_install_path/bin/gfortran"
+ echo "$this_script: export CC=$package_install_path/bin/gcc"
+ export CC="$package_install_path/bin/gcc"
+ echo "$this_script: export CXX=$package_install_path/bin/g++"
+ export CXX="$package_install_path/bin/g++"
+ gfortran_lib_paths="$package_install_path/lib64/:$package_install_path/lib"
+ if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then
+ export LD_LIBRARY_PATH="$gfortran_lib_paths"
else
export LD_LIBRARY_PATH="$gfortran_lib_paths:$LD_LIBRARY_PATH"
fi
@@ -638,7 +641,5 @@ find_or_install()
exit 80
fi # End 'if [[ -x "$package_install_path/bin/$executable" ]]'
- fi # End 'if [[ "$proceed_with_build" == "y" ]]; then'
-
fi # End 'if [[ "$package" != "none" ]]; then'
}
diff --git a/prerequisites/install-functions/print_header.sh b/prerequisites/install-functions/print_header.sh
index 38a1342..08e9a44 100644
--- a/prerequisites/install-functions/print_header.sh
+++ b/prerequisites/install-functions/print_header.sh
@@ -1,4 +1,4 @@
-# shellcheck disable=SC2154
+# shellcheck shell=bash disable=SC2154,SC2148
print_header()
{
clear
@@ -23,12 +23,16 @@ print_header()
fi
popd > /dev/null
echo ""
- printf "${arg_p} will be installed in ${install_path}\n"
+ printf "%s will be installed in %s\n" "${arg_p}" "${install_path}"
echo ""
- printf "Ready to rock and roll? (Y/n)"
- read -r install_now
- echo -e " $install_now\n"
- if [[ "$install_now" == "n" || "$install_now" == "no" ]]; then
- emergency "$this_script: Aborting. [exit 85]\n"
+ if [[ "${arg_y}" == "${__flag_present}" ]]; then
+ info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
+ else
+ printf "Ready to rock and roll? (Y/n)"
+ read -r install_now
+ echo -e " $install_now\n"
+ if [[ "$install_now" == "n" || "$install_now" == "no" ]]; then
+ emergency "$this_script: Aborting. [exit 85]\n"
+ fi
fi
}
diff --git a/prerequisites/install-functions/report_results.sh b/prerequisites/install-functions/report_results.sh
index 4f6ed77..7830591 100644
--- a/prerequisites/install-functions/report_results.sh
+++ b/prerequisites/install-functions/report_results.sh
@@ -1,4 +1,4 @@
-# shellcheck disable=SC2154,SC2129
+# shellcheck shell=bash disable=SC2154,SC2129,SC2148
report_results()
{
# Report installation success or failure:
@@ -36,7 +36,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$gcc_install_path/bin:\$PATH\" " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$gcc_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$gcc_install_path\"/bin \"\$path\") " >> setup.csh
fi
if [[ -d "$gcc_install_path/lib" || -d "$gcc_install_path/lib64" ]]; then
gfortran_lib_paths="$gcc_install_path/lib64/:$gcc_install_path/lib"
@@ -45,7 +45,7 @@ report_results()
echo "else " >> setup.sh
echo " export LD_LIBRARY_PATH=\"$gfortran_lib_paths:\$LD_LIBRARY_PATH\" " >> setup.sh
echo "fi " >> setup.sh
- echo "set LD_LIBRARY_PATH = (\"$gfortran_lib_paths\"/bin "\$LD_LIBRARY_PATH") " >> setup.csh
+ echo "set LD_LIBRARY_PATH = (\"$gfortran_lib_paths\"/bin \"\$LD_LIBRARY_PATH\") " >> setup.csh
fi
echo " " >> setup.sh
mpich_install_path=$("${build_script}" -P mpich)
@@ -55,7 +55,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$mpich_install_path/bin\":\$PATH " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$mpich_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$mpich_install_path\"/bin \"\$path\") " >> setup.csh
fi
cmake_install_path=$("${build_script}" -P cmake)
if [[ -x "$cmake_install_path/bin/cmake" ]]; then
@@ -64,7 +64,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$cmake_install_path/bin\":\$PATH " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$cmake_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$cmake_install_path\"/bin \"\$path\") " >> setup.csh
fi
flex_install_path=$("${build_script}" -P flex)
if [[ -x "$flex_install_path/bin/flex" ]]; then
@@ -72,7 +72,7 @@ report_results()
echo " export PATH=\"$flex_install_path/bin\" " >> setup.sh
echo "else " >> setup.sh
echo " export PATH=\"$flex_install_path/bin\":\$PATH " >> setup.sh
- echo "set path = (\"$flex_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$flex_install_path\"/bin \"\$path\") " >> setup.csh
echo "fi " >> setup.sh
fi
bison_install_path=$("${build_script}" -P bison)
@@ -82,7 +82,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$bison_install_path/bin\":\$PATH " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$bison_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$bison_install_path\"/bin \"\$path\") " >> setup.csh
fi
m4_install_path=$("${build_script}" -P m4)
if [[ -x "$m4_install_path/bin/m4" ]]; then
@@ -91,7 +91,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$m4_install_path/bin\":\$PATH " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$m4_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$m4_install_path\"/bin \"\$path\") " >> setup.csh
fi
opencoarrays_install_path="${install_path}"
if [[ -x "$opencoarrays_install_path/bin/caf" ]]; then
@@ -100,7 +100,7 @@ report_results()
echo "else " >> setup.sh
echo " export PATH=\"$opencoarrays_install_path/bin\":\$PATH " >> setup.sh
echo "fi " >> setup.sh
- echo "set path = (\"$opencoarrays_install_path\"/bin "\$path") " >> setup.csh
+ echo "set path = (\"$opencoarrays_install_path\"/bin \"\$path\") " >> setup.csh
fi
if ${SUDO:-} mv setup.sh "$opencoarrays_install_path"; then
setup_sh_location=$opencoarrays_install_path
@@ -113,14 +113,14 @@ report_results()
setup_csh_location=${PWD}
fi
echo "*** To set up your environment for using caf and cafrun, please ***"
- echo "*** source the installed setup.sh file in a bash shell setup.csh ***"
- echo "*** if you use a C-shell as follows (or add one of the following ***"
- echo "*** statements to your login file: ***"
+ echo "*** source the installed setup.sh file in a bash shell or source ***"
+ echo "*** setup.csh in a C-shell or add one of the following statements ***"
+ echo "*** to your login file: ***"
echo ""
echo " source $setup_sh_location/setup.sh"
echo " source $setup_csh_location/setup.csh"
echo ""
- echo "*** Installation complete. ***"
+ echo "*** Installation complete. ***"
else # Installation failed
diff --git a/prerequisites/install-ofp.sh b/prerequisites/install-ofp.sh
index 7fde8e5..adc96cd 100755
--- a/prerequisites/install-ofp.sh
+++ b/prerequisites/install-ofp.sh
@@ -60,8 +60,9 @@ export __flag_present=1
# shellcheck disable=SC2154
if [[ "${__os}" != "OSX" ]]; then
- info "${__base} currently installs binaries that work only on OS X"
- emergency "To request other platforms, please submit an issue at http://github.com/sourceryinstitute/opencoarrays/issues"
+ echo "Source tranlsation via OFP is currently supported only on OS X."
+ echo "Please submit an issue at http://github.com/sourceryinstitute/opencoarrays/issues."
+ emergency "${PWD}/install-ofp.sh: Aborting."
fi
if [[ $(uname) == "Darwin" ]]; then
@@ -83,8 +84,9 @@ fi
# If -P is passed, print the default installation paths for OFP and its prerequisites.
# Then exit with normal status.
+# shellcheck disable=SC2154
install_path="${arg_i}"
-strategoxt_superbundle_install_path=`${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh -P strategoxt-superbundle`
+strategoxt_superbundle_install_path=$("${OPENCOARRAYS_SRC_DIR}/prerequisites/install-binary.sh" -P strategoxt-superbundle)
# shellcheck disable=SC2154
if [[ "${arg_P}" == "${__flag_present}" ]]; then
echo "strategoxt-superbundle default installation path: ${strategoxt_superbundle_install_path}"
diff --git a/prerequisites/use-case/parse_command_line.sh b/prerequisites/use-case/parse_command_line.sh
index e3e6027..5aad347 100644
--- a/prerequisites/use-case/parse_command_line.sh
+++ b/prerequisites/use-case/parse_command_line.sh
@@ -64,7 +64,7 @@ while read -r line; do
if ! echo "${line}" |egrep '\. Default=' >/dev/null 2>&1; then
eval "${varname}=\"${init}\""
else
- match="$(echo "${line}" |sed 's#^.*Default=\(\)#\1#g')"
+ match="$(sed 's#^.*Default=\(\)#\1#g' <<< "${line}")"
eval "${varname}=\"${match}\""
fi
done < "${__usage}"
diff --git a/prerequisites/use-case/set_common_switches.sh b/prerequisites/use-case/set_common_switches.sh
index 67119c1..4271ff7 100644
--- a/prerequisites/use-case/set_common_switches.sh
+++ b/prerequisites/use-case/set_common_switches.sh
@@ -36,6 +36,7 @@
if [ "${arg_d}" = "1" ]; then
set -o xtrace
LOG_LEVEL="7"
+ export LOG_LEVEL
fi
# verbose mode
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4cbb938..d878158 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(directories_to_build single mpi tests)
+set(directories_to_build mpi tests)
foreach(directory ${directories_to_build})
add_subdirectory(${directory})
endforeach()
diff --git a/src/Makefile b/src/Makefile
index 582da69..9e6fde4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,63 +1,84 @@
+# Makefile
+#
+# -- This Makefile builds the OpenCoarrays libraries using setings in make.inc.
+# (Please edit make.inc before using this Makefile.)
+#
+# Instead of using this Makefile, the preferred alternative is to invoke
+# ./install.sh, which builds the caf compiler wrapper, the cafrun program
+# launcher, the test suite, and any undetected prerequisite packages, and
+# which customizes the build for the environment.
+#
+# Usage (default: GASNET=no):
+# make - Builds libcaf_mpi.a, the MPI transport layer.
+# make GASNET=no all - Builds libcaf_mpi.a and libcaf_gasnet.a.
+# make clean - Deletes *.o files. Retains *.a files.
+#
+# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
+# Copyright (c) 2015-2016, Sourcery, Inc.
+# Copyright (c) 2015-2016, Sourcery Institute
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice, this
+# list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution.
+# 3. Neither the names of the copyright holders nor the names of their 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 THE COPYRIGHT HOLDERS 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.
+
include make.inc
export
+# Conditionally enable the build of the GASNet library libcaf_gasnet.a,
+# an unmaintained but previously functional MPI alterntive.
+ifeq ($(GASNET),yes)
+ gasnet_=gasnet
+endif
+
.PHONY : common
-.PHONY : single
.PHONY : gasnet
.PHONY : mpi
-#.PHONY : armci
+.PHONY : $(gasent_)
+
+all: common mpi $(gasnet_)
mpi: common
$(MAKE) -C $@
-all: common single gasnet mpi # armci
-
common:
$(MAKE) -C $@
-single: common
- $(MAKE) -C $@
-
-#armci: common
-# $(MAKE) -C $@
-
+ifeq ($(GASNET),yes)
gasnet: common
$(MAKE) -C $@
+endif
-test: single gasnet mpi #armci
- $(MAKE) -C tests test
-test-mpi: mpi
- $(MAKE) -C tests test-mpi
-test-gasnet: gasnet
- $(MAKE) -C tests test-gasnet
-#test-armci: armci
-# $(MAKE) -C tests test-armci
-test-single: single
- $(MAKE) -C tests test-single
-
-run: single armci gasnet mpi
- $(MAKE) -C testsuite run
-run-mpi: mpi
- $(MAKE) -C testsuite run-mpi
-run-gasnet: gasnet
- $(MAKE) -C testsuite run-gasnet
-#run-armci: armci
-# $(MAKE) -C testsuite run-armci
-run-single: single
- $(MAKE) -C testsuite run-single
-
+# Delete temporary files files:
clean:
-# $(MAKE) -k -C common clean
-# $(MAKE) -k -C single clean
-# $(MAKE) -k -C gasnet clean
$(MAKE) -k -C mpi clean
-# $(MAKE) -k -C tests clean
-# $(MAKE) -k -C armci clean
+ $(MAKE) -k -C common clean
+ifeq ($(GASNET),yes)
+ $(MAKE) -k -C gasnet clean
+endif
distclean: clean
$(MAKE) -k -C common distclean
-# $(MAKE) -k -C single distclean
$(MAKE) -k -C mpi distclean
-# $(MAKE) -k -C gasnet distclean
-# $(MAKE) -k -C testsuite distclean
-# (MAKE) -k -C armci distclean
+ifeq ($(GASNET),yes)
+ $(MAKE) -k -C gasnet distclean
+endif
diff --git a/src/armci/Makefile b/src/armci/Makefile
deleted file mode 100644
index 01aac76..0000000
--- a/src/armci/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-include ../make.inc
-
-all: libcaf_armci.a
-
-libcaf_armci.a: armci.o ../common/caf_auxiliary.o
- ar rcv $@ armci.o ../common/caf_auxiliary.o
- ranlib $@
-
-.c.o:
- $(CC) $(CFLAGS) $(ARMCI_CFLAGS) -I.. -c $< -o $@
-
-armci.o: armci.c ../libcaf.h ../libcaf-gfortran-descriptor.h
-
-../common/caf_auxiliary.o:
- $(MAKE) -C ../common
-
-clean:
- rm -f armci.o
-
-distclean: clean
- rm -f libcaf_armci.a
diff --git a/src/armci/armci.c b/src/armci/armci.c
deleted file mode 100644
index 7e0e3b4..0000000
--- a/src/armci/armci.c
+++ /dev/null
@@ -1,1006 +0,0 @@
-/* ARMCI implementation of Libcaf
-
-Copyright (c) 2012-2014, Sourcery, Inc.
-All rights reserved.
-
-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 following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the Sourcery, Inc., 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 SOURCERY, INC., 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. */
-
-/****l* armci/armci_caf.c
- * NAME
- * armci_caf
- * SYNOPSIS
- * This program implements the LIBCAF_ARMCI transport layer. This
- * library is incomplete and unsupported. It exists to serve as a
- * starting point for potential future development.
-******
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h> /* For memcpy. */
-#include <stdarg.h> /* For variadic arguments. */
-#include <sched.h> /* For sched_yield. */
-#include <message.h> /* ARMCI and armci_msg_*. */
-#include <complex.h>
-
-#include "libcaf.h"
-
-
-/* Define GFC_CAF_CHECK to enable run-time checking. */
-/* #define GFC_CAF_CHECK 1 */
-
-typedef void ** armci_token_t;
-#define TOKEN(X) ((armci_token_t) (X))
-
-
-static void error_stop (int error) __attribute__ ((noreturn));
-
-/* Global variables. */
-static int caf_this_image;
-static int caf_num_images;
-static int caf_is_finalized;
-
-caf_static_t *caf_static_list = NULL;
-
-static int **arrived;
-static int *orders;
-static int sizeOrders = 0;
-static int *images_full;
-
-/* Keep in sync with single.c. */
-static void
-caf_runtime_error (const char *message, ...)
-{
- va_list ap;
- fprintf (stderr, "Fortran runtime error on image %d: ", caf_this_image);
- va_start (ap, message);
- vfprintf (stderr, message, ap);
- va_end (ap);
- fprintf (stderr, "\n");
-
- /* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
- /* FIXME: Do some more effort than just to abort. */
- armci_msg_abort (EXIT_FAILURE);
-
- /* Should be unreachable, but to make sure also call exit. */
- exit (EXIT_FAILURE);
-}
-
-
-/* Initialize coarray program. This routine assumes that no other
- ARMCI initialization happened before. */
-
-void
-PREFIX (init) (int *argc, char ***argv)
-{
- int ierr=0, i = 0, j = 0;
-
- if (caf_num_images != 0)
- return; /* Already initialized. */
-
- armci_msg_init (argc, argv);
- if (unlikely ((ierr = ARMCI_Init()) != 0))
- caf_runtime_error ("Failure when initializing ARMCI: %d", ierr);
-
- caf_num_images = armci_msg_nproc ();
- caf_this_image = armci_msg_me ();
- caf_this_image++;
- caf_is_finalized = 0;
-
- images_full = (int *) calloc (caf_num_images-1, sizeof (int));
-
- ierr = ARMCI_Create_mutexes (1);
-
- for (i = 0; i < caf_num_images; i++)
- if (i + 1 != caf_this_image)
- {
- images_full[j] = i + 1;
- j++;
- }
-
- orders = calloc (caf_num_images, sizeof (int));
-
- arrived = malloc(sizeof (int *) * caf_num_images);
-
- ierr = ARMCI_Malloc ((void **) arrived, sizeof (int) * caf_num_images);
-
- for (i = 0; i < caf_num_images; i++)
- arrived[caf_this_image-1][i] = 0;
-}
-
-
-/* Finalize coarray program. */
-
-void
-PREFIX (finalize) (void)
-{
- while (caf_static_list != NULL)
- {
- caf_static_t *tmp = caf_static_list->prev;
-
- (void) ARMCI_Free (TOKEN (caf_static_list->token)[caf_this_image-1]);
- free (TOKEN (caf_static_list->token));
- free (caf_static_list);
- caf_static_list = tmp;
- }
-
- (void) ARMCI_Finalize ();
- armci_msg_finalize ();
-
- caf_is_finalized = 1;
-}
-
-
-int
-PREFIX (this_image) (int distance __attribute__ ((unused)))
-{
- return caf_this_image;
-}
-
-
-int
-PREFIX (num_images) (int distance __attribute__ ((unused)),
- int failed __attribute__ ((unused)))
-{
- return caf_num_images;
-}
-
-
-void *
-PREFIX (register) (size_t size, caf_register_t type, caf_token_t *token,
- int *stat, char *errmsg, int errmsg_len)
-{
- int ierr = 0;
-
- if (unlikely (caf_is_finalized))
- goto error;
-
- /* Start ARMCI if not already started. */
- if (caf_num_images == 0)
- PREFIX (init) (NULL, NULL);
-
- *token = malloc (sizeof (armci_token_t));
-
- if (*token == NULL)
- goto error;
-
- *token = malloc (sizeof (void*) * caf_num_images);
- if (TOKEN (*token) == NULL)
- goto error;
-
- ierr = ARMCI_Malloc (TOKEN (*token), size);
-
- if (unlikely (ierr))
- {
- free (TOKEN (*token));
- goto error;
- }
-
- if (type == CAF_REGTYPE_COARRAY_STATIC)
- {
- caf_static_t *tmp = malloc (sizeof (caf_static_t));
- tmp->prev = caf_static_list;
- tmp->token = *token;
- caf_static_list = tmp;
- }
-
- if (stat)
- *stat = 0;
-
- return TOKEN (*token)[caf_this_image-1];
-
-error:
- {
- char *msg;
-
- if (caf_is_finalized)
- msg = "Failed to allocate coarray - there are stopped images";
- else
- msg = "Failed to allocate coarray";
-
- if (stat)
- {
- *stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
- if (errmsg_len > 0)
- {
- int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
- : (int) strlen (msg);
- memcpy (errmsg, msg, len);
- if (errmsg_len > len)
- memset (&errmsg[len], ' ', errmsg_len-len);
- }
- }
- else
- caf_runtime_error (msg);
- }
-
- return NULL;
-}
-
-
-void
-PREFIX (deregister) (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
-{
- int ierr=0;
-
- if (unlikely (caf_is_finalized))
- {
- const char msg[] = "Failed to deallocate coarray - "
- "there are stopped images";
- if (stat)
- {
- *stat = STAT_STOPPED_IMAGE;
-
- if (errmsg_len > 0)
- {
- int len = ((int) sizeof (msg) - 1 > errmsg_len)
- ? errmsg_len : (int) sizeof (msg) - 1;
- memcpy (errmsg, msg, len);
- if (errmsg_len > len)
- memset (&errmsg[len], ' ', errmsg_len-len);
- }
- return;
- }
- caf_runtime_error (msg);
- }
-
- PREFIX (sync_all) (NULL, NULL, 0);
-
- if (stat)
- *stat = 0;
-
- if (unlikely (ierr = ARMCI_Free (TOKEN (*token)[caf_this_image-1])))
- caf_runtime_error ("ARMCI memory freeing failed: Error code %d", ierr);
-
- free (TOKEN (*token));
-}
-
-
-void
-PREFIX (sync_all) (int *stat, char *errmsg, int errmsg_len)
-{
- int ierr=0;
-
- if (unlikely (caf_is_finalized))
- ierr = STAT_STOPPED_IMAGE;
- else
- {
- ARMCI_AllFence ();
- armci_msg_barrier ();
- ierr = 0;
- }
-
- if (stat)
- *stat = ierr;
-
- if (ierr)
- {
- char *msg;
- if (caf_is_finalized)
- msg = "SYNC ALL failed - there are stopped images";
- else
- msg = "SYNC ALL failed";
-
- if (errmsg_len > 0)
- {
- int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
- : (int) strlen (msg);
- memcpy (errmsg, msg, len);
- if (errmsg_len > len)
- memset (&errmsg[len], ' ', errmsg_len-len);
- }
- else
- caf_runtime_error (msg);
- }
-}
-
-
-/* Send scalar (or contiguous) data from buffer to a remote image. */
-
-/* token: The token of the array to be written to. */
-/* offset: Difference between the coarray base address and the actual data, used for caf(3)[2] = 8 or caf[4]%a(4)%b = 7. */
-/* image_index: Index of the coarray (typically remote, though it can also be on this_image). */
-/* data: Pointer to the to-be-transferred data. */
-/* size: The number of bytes to be transferred. */
-/* asynchronous: Return before the data transfer has been complete */
-
-void
-PREFIX (send) (caf_token_t token, size_t offset, int image_index, void *data,
- size_t size, bool async)
-{
- int ierr=0;
-
- if (unlikely (size == 0))
- return; /* Zero-sized array. */
-
- if (image_index == caf_this_image)
- {
- void *dest = (void *) ((char *) TOKEN (token)[image_index-1] + offset);
- memmove (dest, data, size);
- return;
- }
-
- if (!async)
- ierr = ARMCI_Put (data, TOKEN (token)[image_index-1] + offset, size,
- image_index - 1);
- else
- ierr = ARMCI_NbPut (data, TOKEN (token)[image_index-1] + offset, size,
- image_index-1, NULL);
-
- if (ierr != 0)
- error_stop (ierr);
-}
-
-
-/* Send array data from src to dest on a remote image. */
-
-void
-PREFIX (send_desc) (caf_token_t token, size_t offset, int image_index,
- gfc_descriptor_t *dest, gfc_descriptor_t *src, bool async)
-{
- int ierr = 0;
- size_t i, size;
- int j;
- int rank = GFC_DESCRIPTOR_RANK (dest);
-
- size = 1;
- for (j = 0; j < rank; j++)
- {
- ptrdiff_t dimextent = dest->dim[j]._ubound - dest->dim[j].lower_bound + 1;
- if (dimextent < 0)
- dimextent = 0;
- size *= dimextent;
- }
-
- if (size == 0)
- return;
-
- if (PREFIX (is_contiguous) (dest) && PREFIX (is_contiguous) (src))
- {
- void *dst = (void *)((char *) TOKEN (token)[image_index-1] + offset);
-
- if (image_index == caf_this_image)
- memmove (dst, src->base_addr, GFC_DESCRIPTOR_SIZE (dest)*size);
- else if (!async)
- ierr = ARMCI_Put (src->base_addr, dst, GFC_DESCRIPTOR_SIZE (dest)*size,
- image_index - 1);
- else
- ierr = ARMCI_NbPut (src->base_addr, dst,
- GFC_DESCRIPTOR_SIZE (dest)*size,
- image_index-1, NULL);
- if (ierr != 0)
- error_stop (ierr);
- return;
- }
-
- for (i = 0; i < size; i++)
- {
- ptrdiff_t array_offset_dst = 0;
- ptrdiff_t stride = 1;
- ptrdiff_t extent = 1;
- for (j = 0; j < rank-1; j++)
- {
- array_offset_dst += ((i / (extent*stride))
- % (dest->dim[j]._ubound
- - dest->dim[j].lower_bound + 1))
- * dest->dim[j]._stride;
- extent = (dest->dim[j]._ubound - dest->dim[j].lower_bound + 1);
- stride = dest->dim[j]._stride;
- }
- array_offset_dst += (i / extent) * dest->dim[rank-1]._stride;
-
- ptrdiff_t array_offset_sr = 0;
- stride = 1;
- extent = 1;
- for (j = 0; j < GFC_DESCRIPTOR_RANK (src)-1; j++)
- {
- array_offset_sr += ((i / (extent*stride))
- % (src->dim[j]._ubound
- - src->dim[j].lower_bound + 1))
- * src->dim[j]._stride;
- extent = (src->dim[j]._ubound - src->dim[j].lower_bound + 1);
- stride = src->dim[j]._stride;
- }
- array_offset_sr += (i / extent) * src->dim[rank-1]._stride;
-
- void *dst = (void *)((char *) TOKEN (token)[image_index-1] + offset
- + array_offset_dst*GFC_DESCRIPTOR_SIZE (dest));
- void *sr = (void *)((char *) src->base_addr
- + array_offset_sr*GFC_DESCRIPTOR_SIZE (src));
- if (image_index == caf_this_image)
- memmove (dst, sr, GFC_DESCRIPTOR_SIZE (dest));
- else if (!async)
- ierr = ARMCI_Put (sr, dst, GFC_DESCRIPTOR_SIZE (dest), image_index - 1);
- else
- ierr = ARMCI_NbPut (sr, dst, GFC_DESCRIPTOR_SIZE (dest),
- image_index - 1, NULL);
- if (ierr != 0)
- {
- error_stop (ierr);
- return;
- }
- }
-}
-
-
-/* Send scalar data from src to array dest on a remote image. */
-
-void
-PREFIX (send_desc_scalar) (caf_token_t token, size_t offset, int image_index,
- gfc_descriptor_t *dest, void *buffer, bool async)
-{
- int ierr = 0;
- size_t i, size;
- int j;
- int rank = GFC_DESCRIPTOR_RANK (dest);
-
- size = 1;
- for (j = 0; j < rank; j++)
- {
- ptrdiff_t dimextent = dest->dim[j]._ubound - dest->dim[j].lower_bound + 1;
- if (dimextent < 0)
- dimextent = 0;
- size *= dimextent;
- }
-
- for (i = 0; i < size; i++)
- {
- ptrdiff_t array_offset = 0;
- ptrdiff_t stride = 1;
- ptrdiff_t extent = 1;
- for (j = 0; j < rank-1; j++)
- {
- array_offset += ((i / (extent*stride))
- % (dest->dim[j]._ubound
- - dest->dim[j].lower_bound + 1))
- * dest->dim[j]._stride;
- extent = (dest->dim[j]._ubound - dest->dim[j].lower_bound + 1);
- stride = dest->dim[j]._stride;
- }
- array_offset += (i / extent) * dest->dim[rank-1]._stride;
- void *dst = (void *)((char *) TOKEN (token)[image_index-1] + offset
- + array_offset*GFC_DESCRIPTOR_SIZE (dest));
- if (image_index == caf_this_image)
- memmove (dst, buffer, GFC_DESCRIPTOR_SIZE (dest));
- else if (!async)
- ierr = ARMCI_Put (buffer, dst, GFC_DESCRIPTOR_SIZE (dest),
- image_index - 1);
- else
- ierr = ARMCI_NbPut (buffer, dst, GFC_DESCRIPTOR_SIZE (dest),
- image_index-1, NULL);
- if (ierr != 0)
- {
- error_stop (ierr);
- return;
- }
- }
-}
-
-
-void
-PREFIX (get) (caf_token_t token, size_t offset, int image_index, void *data,
- size_t size, bool async)
-{
- int ierr = 0;
-
- if (unlikely (size == 0))
- return; /* Zero-sized array. */
-
- if (image_index == caf_this_image)
- memmove (data, TOKEN (token)[image_index-1] + offset, size);
- else if (async == false)
- ierr = ARMCI_Get (TOKEN (token)[image_index-1] + offset, data, size,
- image_index - 1);
- else
- ierr = ARMCI_NbGet (TOKEN (token)[image_index-1] + offset, data, size,
- image_index - 1, NULL);
-
- if (ierr != 0)
- error_stop (ierr);
-}
-
-
-/* Get array data from a remote src to a local dest. */
-
-void
-PREFIX (get_desc) (caf_token_t token, size_t offset, int image_index,
- gfc_descriptor_t *src, gfc_descriptor_t *dest,
- bool async __attribute__ ((unused)))
-{
- size_t i, size;
- int ierr = 0;
- int j;
- int rank = GFC_DESCRIPTOR_RANK (dest);
-
- size = 1;
- for (j = 0; j < rank; j++)
- {
- ptrdiff_t dimextent = dest->dim[j]._ubound - dest->dim[j].lower_bound + 1;
- if (dimextent < 0)
- dimextent = 0;
- size *= dimextent;
- }
-
- if (size == 0)
- return;
-
- if (PREFIX (is_contiguous) (dest) && PREFIX (is_contiguous) (src))
- {
- void *sr = (void *) ((char *) TOKEN(token)[image_index-1] + offset);
- if (image_index == caf_this_image)
- memmove (dest->base_addr, sr, GFC_DESCRIPTOR_SIZE (dest)*size);
- else if (async == false)
- ierr = ARMCI_Get (sr, dest->base_addr, GFC_DESCRIPTOR_SIZE (dest)*size,
- image_index - 1);
- else
- ierr = ARMCI_NbGet (sr, dest->base_addr,
- GFC_DESCRIPTOR_SIZE (dest)*size, image_index - 1,
- NULL);
- if (ierr != 0)
- error_stop (ierr);
- return;
- }
-
- for (i = 0; i < size; i++)
- {
- ptrdiff_t array_offset_dst = 0;
- ptrdiff_t stride = 1;
- ptrdiff_t extent = 1;
- for (j = 0; j < rank-1; j++)
- {
- array_offset_dst += ((i / (extent*stride))
- % (dest->dim[j]._ubound
- - dest->dim[j].lower_bound + 1))
- * dest->dim[j]._stride;
- extent = (dest->dim[j]._ubound - dest->dim[j].lower_bound + 1);
- stride = dest->dim[j]._stride;
- }
- array_offset_dst += (i / extent) * dest->dim[rank-1]._stride;
-
- ptrdiff_t array_offset_sr = 0;
- stride = 1;
- extent = 1;
- for (j = 0; j < GFC_DESCRIPTOR_RANK (src)-1; j++)
- {
- array_offset_sr += ((i / (extent*stride))
- % (src->dim[j]._ubound
- - src->dim[j].lower_bound + 1))
- * src->dim[j]._stride;
- extent = (src->dim[j]._ubound - src->dim[j].lower_bound + 1);
- stride = src->dim[j]._stride;
- }
- array_offset_sr += (i / extent) * src->dim[rank-1]._stride;
-
- void *sr = (void *)((char *) TOKEN (token)[image_index-1] + offset
- + array_offset_sr*GFC_DESCRIPTOR_SIZE (src));
- void *dst = (void *)((char *) dest->base_addr
- + array_offset_dst*GFC_DESCRIPTOR_SIZE (dest));
- if (image_index == caf_this_image)
- memmove (dst, sr, GFC_DESCRIPTOR_SIZE (dest));
- else if (async == false)
- ierr = ARMCI_Get (sr, dst, GFC_DESCRIPTOR_SIZE (dest), image_index - 1);
- else
- ierr = ARMCI_NbGet (sr, dst, GFC_DESCRIPTOR_SIZE (dest),
- image_index - 1, NULL);
- if (ierr != 0)
- error_stop (ierr);
- }
-}
-
-
-/* SYNC IMAGES. Note: SYNC IMAGES(*) is passed as count == -1 while
- SYNC IMAGES([]) has count == 0. Note further that SYNC IMAGES(*)
- is not equivalent to SYNC ALL. */
-
-void
-PREFIX (sync_images) (int count, int images[], int *stat, char *errmsg,
- int errmsg_len)
-{
- int i, ierr=0;
- bool freeToGo = false;
-
- if (count == 0 || (count == 1 && images[0] == caf_this_image))
- {
- if (stat)
- *stat = 0;
- return;
- }
-
-#ifdef GFC_CAF_CHECK
- {
- for (i = 0; i < count; i++)
- if (images[i] < 1 || images[i] > caf_num_images)
- {
- fprintf (stderr, "COARRAY ERROR: Invalid image index %d to SYNC "
- "IMAGES", images[i]);
- error_stop (1);
- }
- }
-#endif
-
- /* FIXME: SYNC IMAGES with a nontrivial argument cannot easily be
- mapped to ARMCI communicators. Thus, exist early with an error message. */
-
- /* Handle SYNC IMAGES(*). */
- if (unlikely (caf_is_finalized))
- ierr = STAT_STOPPED_IMAGE;
- else
- {
- /* Insert orders. */
- if(count == -1)
- {
- for (i = 0; i < caf_num_images - 1; i++)
- orders[images_full[i]-1]++;
- count = caf_num_images-1;
- images = images_full;
- }
- else
- {
- for (i = 0; i < count; i++)
- orders[images[i]-1]++;
- }
-
- /* Sending ack. */
-
- int val;
-
- for (i = 0; i < count; i++)
- {
- ARMCI_Lock (0, images[i]-1);
-
- val = ARMCI_GetValueInt (
- (void *) &arrived[images[i]-1][caf_this_image-1],
- images[i]-1);
- val++;
- ierr = ARMCI_PutValueInt (
- val, (void *) &arrived[images[i]-1][caf_this_image-1],
- images[i]-1);
- ARMCI_Unlock (0, images[i]-1);
- }
-
- while (!freeToGo)
- {
- ARMCI_Lock (0, caf_this_image-1);
-
- sizeOrders = 0;
-
- for (i = 0; i < caf_num_images; i++)
- {
- if (orders[i] != 0)
- {
- sizeOrders++;
- val = ARMCI_GetValueInt (
- (void *) &arrived[caf_this_image-1][i],
- caf_this_image-1);
- /* val = arrived[caf_this_image-1][i]; */
- if (val != 0)
- {
- orders[i]--;
- sizeOrders--;
- val--;
- ierr = ARMCI_PutValueInt (
- val, (void *) &arrived[caf_this_image-1][i],
- caf_this_image-1);
- }
- }
- }
-
- if (sizeOrders == 0)
- freeToGo=true;
-
- ARMCI_Unlock (0, caf_this_image-1);
- sched_yield ();
- }
-
- freeToGo = false;
- }
-
- if (stat)
- *stat = ierr;
-
- if (ierr)
- {
- char *msg;
- if (caf_is_finalized)
- msg = "SYNC IMAGES failed - there are stopped images";
- else
- msg = "SYNC IMAGES failed";
-
- if (errmsg_len > 0)
- {
- int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
- : (int) strlen (msg);
- memcpy (errmsg, msg, len);
- if (errmsg_len > len)
- memset (&errmsg[len], ' ', errmsg_len-len);
- }
- else
- caf_runtime_error (msg);
- }
-}
-
-#if 0
-
-/* FIXME: The following needs to be fixed - in particular for result_image > 0;
- It is unclear what's the difference between armci_msg_igop and
- armci_msg_reduce; in particular, how to state that the result is only saved
- on a certain image? */
-static void
-co_reduce_2 (char *op, int result_image, gfc_descriptor_t *source,
- gfc_descriptor_t *result, void *sr, void *dst,
- size_t size)
-{
- void *arg;
- if (result && GFC_DESCRIPTOR_TYPE (source) != BT_COMPLEX)
- memmove (dst, sr, GFC_DESCRIPTOR_SIZE (source)*size);
- else
- arg = sr;
-
- if (result_image == 0)
- switch (GFC_DESCRIPTOR_TYPE (source))
- {
- BT_INTEGER:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (int))
- armci_msg_igop (arg, size, op);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (long))
- armci_msg_lgop (arg, size, op);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (long long))
- armci_msg_llgop (arg, size, op);
- else
- goto error;
- break;
- BT_REAL:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (float))
- armci_msg_fgop (arg, size, op);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (double))
- armci_msg_dgop (arg, size, op);
- else
- goto error;
- break;
- BT_COMPLEX:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (float) && size == 1)
- {
- float re = __real__ *(_Complex float*) sr;
- float im = __imag__ *(_Complex float*) sr;
- armci_msg_fgop (&re, 1, op);
- armci_msg_fgop (&im, 1, op);
- if (result)
- *(_Complex float*) dst = re + im * _Complex_I;
- else
- *(_Complex float*) sr = re + im * _Complex_I;
- }
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (double) && size == 1)
- {
- double re = __real__ *(_Complex double*) sr;
- double im = __imag__ *(_Complex double*) sr;
- armci_msg_dgop (&re, 1, op);
- armci_msg_dgop (&im, 1, op);
- if (result)
- *(_Complex double*) dst = re + im * _Complex_I;
- else
- *(_Complex double*) sr = re + im * _Complex_I;
- }
- else
- goto error;
- break;
- default:
- goto error;
- }
- else
- switch (GFC_DESCRIPTOR_TYPE (source))
- {
- BT_INTEGER:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (int))
- armci_msg_reduce(arg, size, op, ARMCI_INT, result_image-1);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (long))
- armci_msg_reduce(arg, size, op, ARMCI_LONG, result_image-1);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (long long))
- armci_msg_reduce(arg, size, op, ARMCI_LONG_LONG, result_image-1);
- else
- goto error;
- break;
- BT_REAL:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (float))
- armci_msg_reduce(arg, size, op, ARMCI_FLOAT, result_image-1);
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (double))
- armci_msg_reduce(arg, size, op, ARMCI_DOUBLE, result_image-1);
- else
- goto error;
- break;
- BT_COMPLEX:
- if (GFC_DESCRIPTOR_SIZE (source) == sizeof (float) && size == 1)
- {
- double re = __real__ *(_Complex double*) sr;
- double im = __imag__ *(_Complex double*) sr;
- armci_msg_reduce(&re, 1, op, ARMCI_FLOAT, result_image-1);
- armci_msg_reduce(&im, 1, op, ARMCI_FLOAT, result_image-1);
- if (result)
- *(_Complex double*) dst = re + im * _Complex_I;
- else
- *(_Complex double*) sr = re + im * _Complex_I;
- }
- else if (GFC_DESCRIPTOR_SIZE (source) == sizeof (double) && size == 1)
- {
- double re = __real__ *(_Complex double*) sr;
- double im = __imag__ *(_Complex double*) sr;
- armci_msg_reduce(&re, 1, op, ARMCI_DOUBLE, result_image-1);
- armci_msg_reduce(&im, 1, op, ARMCI_DOUBLE, result_image-1);
- if (result)
- *(_Complex double*) dst = re + im * _Complex_I;
- else
- *(_Complex double*) sr = re + im * _Complex_I;
- }
- else
- goto error;
- break;
- default:
- goto error;
- }
- return;
-error:
- /* FIXME: Handle the other data types as well. */
- caf_runtime_error ("Unsupported data type in collective\n");
-}
-
-
-static void
-co_reduce_1 (char *op, gfc_descriptor_t *source,
- gfc_descriptor_t *result, int result_image, int *stat,
- char *errmsg, int errmsg_len)
-{
- void *source2, *result2;
- size_t i, size;
- int j, ierr;
- int rank = GFC_DESCRIPTOR_RANK (source);
-
- if (stat)
- *stat = 0;
-
- size = 1;
- for (j = 0; j < rank; j++)
- {
- ptrdiff_t dimextent = source->dim[j]._ubound
- - source->dim[j].lower_bound + 1;
- if (dimextent < 0)
- dimextent = 0;
- size *= dimextent;
- }
-
- if (size = 1
- || (GFC_DESCRIPTOR_TYPE (source) != BT_COMPLEX
- && PREFIX (is_contiguous) (source)
- && (!result || PREFIX (is_contiguous) (result))))
- {
- source2 = source->base_addr;
- result2 = result ? result->base_addr : NULL;
- co_reduce_2 (op, result_image, source, result, source2, result2, size);
- return;
- }
-
- for (i = 0; i < size; i++)
- {
- ptrdiff_t array_offset_sr = 0;
- ptrdiff_t stride = 1;
- ptrdiff_t extent = 1;
- for (j = 0; j < GFC_DESCRIPTOR_RANK (source)-1; j++)
- {
- array_offset_sr += ((i / (extent*stride))
- % (source->dim[j]._ubound
- - source->dim[j].lower_bound + 1))
- * source->dim[j]._stride;
- extent = (source->dim[j]._ubound - source->dim[j].lower_bound + 1);
- stride = source->dim[j]._stride;
- }
- array_offset_sr += (i / extent) * source->dim[rank-1]._stride;
- void *sr = (void *)((char *) source->base_addr
- + array_offset_sr*GFC_DESCRIPTOR_SIZE (source));
- void *dst = NULL;
- if (result)
- {
- ptrdiff_t array_offset_dst = 0;
- stride = 1;
- extent = 1;
- for (j = 0; j < rank-1; j++)
- {
- array_offset_dst += ((i / (extent*stride))
- % (result->dim[j]._ubound
- - result->dim[j].lower_bound + 1))
- * result->dim[j]._stride;
- extent = (result->dim[j]._ubound - result->dim[j].lower_bound + 1);
- stride = result->dim[j]._stride;
- }
- array_offset_dst += (i / extent) * result->dim[rank-1]._stride;
- dst = (void *)((char *) result->base_addr
- + array_offset_dst*GFC_DESCRIPTOR_SIZE (source));
- }
-
- result2 = result ? dst : NULL;
- co_reduce_2 (op, result_image, source, result, sr, result2, 1);
- }
- return;
-}
-
-
-void
-PREFIX (co_sum) (gfc_descriptor_t *source, gfc_descriptor_t *result,
- int result_image, int *stat, char *errmsg, int errmsg_len)
-{
- co_reduce_1 ("+", source, result, result_image, stat, errmsg, errmsg_len);
-}
-
-
-void
-PREFIX (co_min) (gfc_descriptor_t *source, gfc_descriptor_t *result,
- int result_image, int *stat, char *errmsg, int errmsg_len)
-{
- co_reduce_1 ("min", source, result, result_image, stat, errmsg, errmsg_len);
-}
-
-
-void
-PREFIX (co_max) (gfc_descriptor_t *source, gfc_descriptor_t *result,
- int result_image, int *stat, char *errmsg, int errmsg_len)
-{
- co_reduce_1 ("max", source, result, result_image, stat, errmsg, errmsg_len);
-}
-#endif
-
-
-/* ERROR STOP the other images. */
-
-static void
-error_stop (int error)
-{
- /* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
- /* FIXME: Do some more effort than just ARMCI_Error. */
-// ARMCI_Error ("Aborting calculation", error);
- ARMCI_Error (NULL, error);
-
- /* Should be unreachable, but to make sure also call exit. */
- exit (error);
-}
-
-
-/* ERROR STOP function for string arguments. */
-
-void
-PREFIX (error_stop_str) (const char *string, int32_t len)
-{
- fputs ("ERROR STOP ", stderr);
- while (len--)
- fputc (*(string++), stderr);
- fputs ("\n", stderr);
-
- error_stop (1);
-}
-
-
-/* ERROR STOP function for numerical arguments. */
-
-void
-PREFIX (error_stop) (int32_t error)
-{
- fprintf (stderr, "ERROR STOP %d\n", error);
- error_stop (error);
-}
diff --git a/src/extensions/caf-foot b/src/extensions/caf-foot
index 552945a..f3c1a24 100755
--- a/src/extensions/caf-foot
+++ b/src/extensions/caf-foot
@@ -60,10 +60,8 @@ if [ $# == 0 ]; then
exit 1
fi
-# Default to "mpif90" Fortran compiler if environment variable CAFC has zero length:
-if [ -z "$CAFC" ]; then
- CAFC=mpif90
-fi
+# Default to "mpif90" Fortran compiler if environment variable CAFC is empty or unset:
+CAFC=${CAFC:-mpif90}
# TODO -- improve the syntax of the "set" command below to accepted an unlimited number of arguments
max_arguments=100
diff --git a/src/make.inc b/src/make.inc
index 1546113..1ac5322 100644
--- a/src/make.inc
+++ b/src/make.inc
@@ -13,12 +13,6 @@ LDFLAGS +=
SINGLE_CFLAGS += -Wall -Wextra
-ARMCI_DIR =
-ARMCI_CFLAGS += -I$(ARMCI_DIR)/include/ -Werror -Wall -Wextra
-ARMCI_LDFLAGS += -L$(ARMCI_DIR)/lib -L$(ARMCI_DIR)/lib64 -larmci
-ARMCI_CC = mpicc
-ARMCI_RUN = mpirun -np 2
-
MPI_EXTRA_FLAGS = -Wall -Wextra -Wno-error=cpp -Wno-error=unused-parameter -DSTRIDED#-DNONBLOCKING_PUT -DCAF_MPI_LOCK_UNLOCK
MPI_CFLAGS += $(MPI_EXTRA_FLAGS)
#MPICC =
diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt
index 9c4fb5a..029991e 100644
--- a/src/mpi/CMakeLists.txt
+++ b/src/mpi/CMakeLists.txt
@@ -53,6 +53,11 @@ if(opencoarrays_aware_compiler)
else()
file(APPEND "${compiler_wrapper}" "caf_compiler=false\n")
endif()
+
+if ( DEFINED ENV{FC} )
+ file(APPEND "${compiler_wrapper}" "CAFC=$ENV{FC}\n")
+endif ()
+
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
file(APPEND "${compiler_wrapper}" "linux=true\n")
endif()
diff --git a/src/mpi/mpi_caf.c b/src/mpi/mpi_caf.c
index 55b288d..a909916 100644
--- a/src/mpi/mpi_caf.c
+++ b/src/mpi/mpi_caf.c
@@ -533,9 +533,10 @@ void *
MPI_Win_flush(caf_this_image-1, *p);
# endif // CAF_MPI_LOCK_UNLOCK
free(init_array);
- PREFIX(sync_all) (NULL,NULL,0);
}
+ PREFIX(sync_all) (NULL,NULL,0);
+
caf_static_t *tmp = malloc (sizeof (caf_static_t));
tmp->prev = caf_tot;
tmp->token = *token;
diff --git a/src/tests/integration/CMakeLists.txt b/src/tests/integration/CMakeLists.txt
index 7261163..6b19a01 100644
--- a/src/tests/integration/CMakeLists.txt
+++ b/src/tests/integration/CMakeLists.txt
@@ -1,6 +1,6 @@
if (opencoarrays_aware_compiler)
add_subdirectory(coarrayHelloWorld)
- if (NOT (DEFINED ENV{TRAVIS}))
+ if (NOT ("${CMAKE_BUILD_TYPE}" MATCHES "CodeCoverage"))
add_subdirectory(dist_transpose )
endif()
add_subdirectory(pde_solvers)
diff --git a/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt b/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
index f236f6f..6fdb52f 100644
--- a/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
+++ b/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
@@ -1,5 +1,5 @@
# checking whether the machine is of type 64-bit before proceeding further
-if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "LINUX") )
+if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") )
# Default to older SSE-instruction-based FFT library
if (NOT (DEFINED ENV{TRAVIS}))
if (LEGACY_ARCHITECTURE OR (NOT DEFINED(LEGACY_ARCHITECTURE)))
diff --git a/src/tests/unit/simple/Makefile b/src/tests/unit/simple/Makefile
index 2938cf8..a056bfd 100644
--- a/src/tests/unit/simple/Makefile
+++ b/src/tests/unit/simple/Makefile
@@ -1,4 +1,4 @@
-.SUFFIXES: .f90 .armci .mpi .gasnet
+.SUFFIXES: .f90 .mpi .gasnet
TOP=../../..
include $(TOP)/make.inc
@@ -7,24 +7,20 @@ OBJS=increment_my_neighbor.o add_myself_to_my_neighbor.o send_array_test.o
EXES=$(OBJS:.o=.exe)
-all: $(OBJS) armci gasnet mpi
+all: $(OBJS) gasnet mpi
clean:
- /bin/rm -fr *.o *.armci *.mpi *.gasnet
+ /bin/rm -fr *.o *.mpi *.gasnet
mpi: $(EXES:.exe=.mpi)
-armci: $(EXES:.exe=.armci)
-
gasnet: $(EXES:.exe=.gasnet)
.o.mpi:
$(MPFC) -o $@ $< -lcaf_mpi -L$(TOP)/mpi
-.o.armci:
- $(MPFC) -o $@ $< -lcaf_armci -L$(TOP)/armci $(ARMCI_LDFLAGS)
.o.gasnet:
$(MPFC) -o $@ $< -lcaf_gasnet -L$(TOP)/gasnet $(GASNET_LDFLAGS)
.f90.o:
diff --git a/src/tests/unit/sync/CMakeLists.txt b/src/tests/unit/sync/CMakeLists.txt
index c8ba3bf..5b5926d 100644
--- a/src/tests/unit/sync/CMakeLists.txt
+++ b/src/tests/unit/sync/CMakeLists.txt
@@ -7,17 +7,5 @@ target_link_libraries(syncimages OpenCoarrays)
add_executable(duplicate_syncimages duplicate_syncimages.f90)
target_link_libraries(duplicate_syncimages OpenCoarrays)
-#add_executable(syncimages_status syncimages_status.f90)
-#target_link_libraries(syncimages_status OpenCoarrays)
-
-#add_executable(send_array send_array_test.f90)
-#target_link_libraries(send_array OpenCoarrays)
-
-#add_executable(get_with_offset_1d get_with_offset_1d.f90)
-#target_link_libraries(get_with_offset_1d OpenCoarrays)
-
-#add_executable(whole_get_array whole_get_array.f90)
-#target_link_libraries(whole_get_array OpenCoarrays)
-
-#add_executable(strided_get strided_get.f90)
-#target_link_libraries(strided_get OpenCoarrays)
+add_executable(syncimages_status syncimages_status.f90)
+target_link_libraries(syncimages_status OpenCoarrays)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/open-coarrays.git
More information about the debian-science-commits
mailing list