Skip to content

Commit a7ad5ac

Browse files
authored
Merge pull request #9 from rikigigi/devel
fixed macos compilation, added ci for macos, fixed return value of cl…
2 parents eacf836 + c3d687c commit a7ad5ac

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

.github/workflows/cmake.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ jobs:
1616
# well on Windows or Mac. You can convert this to a matrix build if you need
1717
# cross-platform coverage.
1818
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19-
runs-on: ubuntu-latest
19+
runs-on: ${{ matrix.os }}
2020

21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest, macos-latest ]
24+
python-version: [ "3.7" ]
2125
steps:
2226
- uses: actions/checkout@v2
23-
27+
- name: Setup python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
architecture: x64
2432
- name: Configure CMake
2533
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
2634
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -32,7 +40,7 @@ jobs:
3240
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
3341
sudo -E ${{github.workspace}}/install/install_python.sh
3442
env:
35-
SP_DIR: /usr/lib/python3/dist-packages
43+
SP_DIR: ${{github.workspace}}/tests
3644
SOURCE_DIR: ${{github.workspace}}
3745
BUILD_DIR: ${{github.workspace}}/build
3846

@@ -43,10 +51,11 @@ jobs:
4351
run: |
4452
ctest -C ${{env.BUILD_TYPE}}
4553
../install/install_test.sh
46-
cd ../tests/ && pytest -sv .
54+
cd ../tests/ && python -m pytest -sv .
4755
- name: TestCli
4856
run: |
4957
${{github.workspace}}/tests/test_cli.sh
5058
env:
5159
SOURCE_DIR: ${{github.workspace}}
5260
BUILD_DIR: ${{github.workspace}}/build
61+
PYTHONPATH: /usr/lib/python${{ matrix.python-version }}/dist-packages

analisi/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ int main(int argc, char ** argv)
239239

240240
if (argc<=1 || ( (output_conversion!="" || output_conversion_gro.size()>0 ) && input=="") ||vm.count("help")|| (vm.count("loginput")==0 && ( debug2 || heat_coeff ) ) || skip<=0 || stop_acf<0 || final<0 || (!sub_mean && (sub_mean_start!=0) ) || sub_mean_start<0 || !(kk_l.size()==0 || kk_l.size()==2)){
241241
std::cout << options << "\n";
242+
if (vm.count("help"))
243+
return 0;
242244
return 1;
243245
}
244246

lib/include/calcolamultithread.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ template <class T, int FLAGS_T = CalcolaMultiThread_Flags::PARALLEL_SPLIT_AVERAG
2828
class CalcolaMultiThread
2929
{
3030
public:
31-
CalcolaMultiThread(unsigned int nthreads=0, unsigned int skip=0, int natoms=0) : nthreads{nthreads},skip{skip},ntimesteps{0},natoms{natoms}
31+
CalcolaMultiThread(ssize_t nthreads=0, ssize_t skip=0, size_t natoms=0) : nthreads{nthreads},skip{skip},ntimesteps{0},natoms{natoms}
3232
{
3333
if (nthreads==0) nthreads=1;
3434
if (skip==0) skip=1;
3535

3636
}
3737
static constexpr int FLAGS=FLAGS_T;
3838

39-
std::pair<int,int> splitter(int ith, int nthreads, int primo) const {
40-
std::pair<int,int> res;
39+
std::pair<size_t,size_t> splitter(size_t ith, size_t primo) const {
40+
std::pair<size_t,size_t> res;
4141
res.first=ith*npassith;
4242
if (ith==nthreads-1) {
4343
res.second=end;
@@ -73,7 +73,7 @@ class CalcolaMultiThread
7373
}
7474
}
7575

76-
void calcola(unsigned int primo){
76+
void calcola(size_t primo){
7777
init_split();
7878
if constexpr (!!(FLAGS & CalcolaMultiThread_Flags::CALL_CALC_INIT)) {
7979
static_cast<T*>(this)->calc_init(primo);
@@ -83,7 +83,7 @@ class CalcolaMultiThread
8383
for (ssize_t i=i0;i<i1;i+=skip){ //loop over trajectory. Can be a loop over a single value if disabled
8484
for (unsigned int ith=0;ith<nthreads;++ith){
8585
threads.push_back(std::thread([&,ith,t,i](){
86-
auto range=splitter(ith,nthreads,primo);
86+
auto range=splitter(ith,primo);
8787
// calculate given start and stop timestep. note that & captures everything, user must take care of multithread safety of calc_single_th function
8888
// select a different signature of the calculation function depending on where the loops (if present) are parallelized
8989
if constexpr (FLAGS & CalcolaMultiThread_Flags::PARALLEL_LOOP_AVERAGE && (FLAGS & CalcolaMultiThread_Flags::PARALLEL_LOOP_TIME)) {
@@ -144,8 +144,7 @@ class CalcolaMultiThread
144144
ssize_t nthreads,skip,ntimesteps, leff;
145145

146146
private:
147-
size_t npassith,end;
148-
ssize_t natoms;
147+
size_t npassith,end, natoms;
149148
ssize_t t0,t1,i0,i1;
150149
};
151150

tests/src/test_sh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ struct ShFixture{
1515
~ShFixture(){}
1616
TrajSetup traj;
1717
unsigned int nbin;
18-
int natoms,ntypes;
18+
size_t natoms;
19+
int ntypes;
1920
SphericalCorrelations<l,double,Traiettoria> sh;
2021
DataRegression<double> data;
2122
double workspace[(l+1)*(l+1)], cheby[(l+1)*2];

tests/test_cli.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ TESTS=( "MSD_normal_full" "-i $INPUT -Q"
3131
N_arr=${#TESTS[@]}
3232
N=$(( N_arr - 1 ))
3333
RETURN=0
34+
FLIST=""
3435
for i in $(seq 0 2 $N )
3536
do
3637
ip=$(( i + 1 ))
@@ -41,12 +42,16 @@ do
4142
if [ -f "$FTEST" ]
4243
then
4344
OUTPUT_F="`cat $FTEST`"
44-
45-
if [ -z "`diff <(echo "$OUTPUT") <(echo "$OUTPUT_F")`" ]
45+
#the sign of nan is not defined by the standard
46+
DIFF="`diff <(echo "$OUTPUT" | sed 's/-nan/nan/g') <(echo "$OUTPUT_F" | sed 's/-nan/nan/g') || true `"
47+
if [ -z "$DIFF" ]
4648
then
4749
echo SUCCESS $NAME
4850
else
4951
echo FAILED $NAME
52+
echo "$DIFF"
53+
FLIST="$FLIST
54+
FAILED $NAME"
5055
RETURN=$(( RETURN + 1 ))
5156
fi
5257
else
@@ -55,4 +60,5 @@ do
5560
fi
5661

5762
done
63+
echo "$FLIST"
5864
exit $RETURN

0 commit comments

Comments
 (0)