Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build the samples on the CI services #649

Merged
merged 5 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ addons:
- scons
- boost
- python
- libomp
ssh_known_hosts:
- cantera.org

Expand Down Expand Up @@ -50,6 +51,7 @@ script: |
set -e
scons build -j2 python_cmd=/usr/bin/python3 VERBOSE=y python_package=full blas_lapack_libs=lapack,blas optimize=n coverage=y
scons test
scons samples
scons build sphinx_docs=y doxygen_docs=y sphinx_cmd="/usr/bin/python3 `which sphinx-build`"
if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]] && [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${TRAVIS_REPO_SLUG}" == "Cantera/cantera" ]]; then
openssl aes-256-cbc -k "${ctdeploy_pass}" -in ./doc/ctdeploy_key.enc -out ./doc/ctdeploy_key -d
Expand All @@ -75,6 +77,7 @@ script: |
else
scons build -j2 python_cmd=python3 VERBOSE=y python_package=full blas_lapack_libs=lapack,blas optimize=n coverage=y
scons test
scons samples
fi
after_success: |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
Expand Down
14 changes: 11 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,15 @@ defaults.noDebugLinkFlags = ''
defaults.warningFlags = '-Wall'
defaults.buildPch = False
env['pch_flags'] = []
env['openmp_flag'] = '-fopenmp' # used to generate sample build scripts
env['openmp_flag'] = ['-fopenmp'] # used to generate sample build scripts

env['using_apple_clang'] = False
# Check if this is actually Apple's clang on macOS
if env['OS'] == 'Darwin':
result = subprocess.check_output([env.subst('$CC'), '--version']).decode('utf-8')
if 'clang' in result.lower() and result.startswith('Apple LLVM'):
env['using_apple_clang'] = True
env['openmp_flag'].insert(0, '-Xpreprocessor')

if 'gcc' in env.subst('$CC') or 'gnu-cc' in env.subst('$CC'):
defaults.optimizeCcFlags += ' -Wno-inline'
Expand All @@ -276,13 +284,13 @@ elif env['CC'] == 'cl': # Visual Studio
defaults.warningFlags = '/W3'
defaults.buildPch = True
env['pch_flags'] = ['/FIpch/system.h']
env['openmp_flag'] = '/openmp'
env['openmp_flag'] = ['/openmp']

elif 'icc' in env.subst('$CC'):
defaults.cxxFlags = '-std=c++0x'
defaults.ccFlags = '-vec-report0 -diag-disable 1478'
defaults.warningFlags = '-Wcheck'
env['openmp_flag'] = '-openmp'
env['openmp_flag'] = ['-openmp']

elif 'clang' in env.subst('$CC'):
defaults.ccFlags = '-fcolor-diagnostics'
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install:
build_script:
- cmd: C:\Python37-x64\Scripts\scons build -j2 boost_inc_dir=C:\Libraries\boost_1_62_0 debug=n VERBOSE=y python_package=full
- cmd: C:\Python37-x64\Scripts\scons samples

test_script:
- ps: |
Expand Down
5 changes: 4 additions & 1 deletion include/cantera/zerodim.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define CT_INCL_ZERODIM_H

// reactor network
#include "zeroD/ReactorNet.h"
#include "cantera/zeroD/ReactorNet.h"

// reactors
#include "cantera/zeroD/Reservoir.h"
Expand All @@ -31,4 +31,7 @@
#include "cantera/zeroD/FlowDeviceFactory.h"
#include "cantera/zeroD/WallFactory.h"

// func1
#include "cantera/numerics/Func1.h"

#endif
13 changes: 9 additions & 4 deletions samples/cxx/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ for subdir, name, extensions, openmp in samples:
localenv = env.Clone()
if openmp:
localenv.Append(CXXFLAGS=env['openmp_flag'], LINKFLAGS=env['openmp_flag'])
if env['using_apple_clang']:
localenv.Append(LIBS=['omp'])

localenv['cmake_extra'] = """
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
"""
elif env["OS"] == "Darwin":
localenv["cmake_extra"] = "find_library(ACCELERATE_FRAMEWORK Accelerate)"
else:
localenv['cmake_extra'] = ''

if env["OS"] == "Darwin":
localenv["cmake_extra"] += "find_library(ACCELERATE_FRAMEWORK Accelerate)"

localenv.Append(LIBS=env['cantera_libs'])

buildSample(localenv.Program, pjoin(subdir, name),
mglob(localenv, subdir, *extensions),
CPPPATH=['#include'],
LIBS=env['cantera_libs'])
CPPPATH=['#include', env['boost_inc_dir']])

# Note: These Makefiles and SConstruct files are automatically installed
# by the "RecursiveInstall" that grabs everything in the cxx directory.
Expand Down
8 changes: 4 additions & 4 deletions samples/cxx/openmp_ignition/openmp_ignition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ void run()
}

// Points at which to compute ignition delay time
size_t nPoints = 50;
int nPoints = 50;
vector_fp T0(nPoints);
vector_fp ignition_time(nPoints);
for (size_t i = 0; i < nPoints; i++) {
for (int i = 0; i < nPoints; i++) {
T0[i] = 1000 + 500 * ((float) i) / ((float) nPoints);
}

Expand All @@ -51,7 +51,7 @@ void run()
// thread in cases where the workload is biased, e.g. calculations for low
// T0 take longer than calculations for high T0.
#pragma omp parallel for schedule(static, 1)
for (size_t i = 0; i < nPoints; i++) {
for (int i = 0; i < nPoints; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needing to change this to a signed type is unfortunate. In this case, nPoints should also be changed to an int, as well other variables which are compared to nPoints (i.e. the loop index in the preceding loop) to avoid compiler warnings about "comparison between signed and unsigned integer expressions".

// Get the Cantera objects that were initialized for this thread
size_t j = omp_get_thread_num();
IdealGasMix& gas = *gases[j];
Expand All @@ -76,7 +76,7 @@ void run()
// Print the computed ignition delays
writelog(" T (K) t_ig (s)\n");
writelog("-------- ----------\n");
for (size_t i = 0; i < nPoints; i++) {
for (int i = 0; i < nPoints; i++) {
writelog("{: 8.1f} {: 10.3e}\n", T0[i], ignition_time[i]);
}
}
Expand Down