Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
janzenchoi authored Aug 18, 2023
2 parents 178263c + 1f0ae09 commit 219c585
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
jobs:
build_wheels_linux_mac:
env:
CIBW_SKIP: cp311-* *-manylinux_i686 pp* *_ppc641e *_s390x *_aarch64 *musllinux*
CIBW_SKIP: cp311-* cp312-* cp313-* *-manylinux_i686 pp* *_ppc641e *_s390x *_aarch64 *musllinux*
CIBW_BEFORE_ALL_LINUX: yum -y install cmake cmake3 blas-devel lapack-devel && alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 --slave /usr/local/bin/ctest ctest /usr/bin/ctest --slave /usr/local/bin/cpack cpack /usr/bin/cpack --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake --family cmake && alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 --family cmake
CIBW_BEFORE_ALL_MACOS: brew install cmake openblas superlu gfortran
CIBW_BEFORE_BUILD: "cmake -DCMAKE_BUILD_TYPE=Release -DUSE_OPENMP=OFF . && cmake --build . && rm CMakeCache.txt && rm -rf CMakeFiles && pip install -r requirements.txt"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: pull_request
jobs:
test_wheels_linux_mac:
env:
CIBW_SKIP: cp311-* *-manylinux_i686 pp* *_ppc641e *_s390x *_aarch64 *musllinux*
CIBW_SKIP: cp311-* cp312-* cp313-* *-manylinux_i686 pp* *_ppc641e *_s390x *_aarch64 *musllinux*
CIBW_BEFORE_ALL_LINUX: yum -y install cmake cmake3 blas-devel lapack-devel && alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 --slave /usr/local/bin/ctest ctest /usr/bin/ctest --slave /usr/local/bin/cpack cpack /usr/bin/cpack --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake --family cmake && alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 --family cmake
CIBW_BEFORE_ALL_MACOS: brew install cmake openblas superlu gfortran
CIBW_BEFORE_BUILD: "cmake -DCMAKE_BUILD_TYPE=Release -DUSE_OPENMP=OFF . && cmake --build . && rm CMakeCache.txt && rm -rf CMakeFiles && pip install -r requirements.txt"
Expand Down
2 changes: 2 additions & 0 deletions include/nemlerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class NEML_EXPORT NonlinearSolverError: public NEMLError {
NonlinearSolverError(std::string msg);
};

enum class ExceptionType { NEMLError, LinalgError, NonlinearSolverError };

} // namespace neml

#endif // NEMLERROR
3 changes: 3 additions & 0 deletions neml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
ndir = os.path.dirname(__file__)
os.environ['PATH'] += os.pathsep + ndir

if os.name == 'nt':
os.add_dll_directory(ndir)

import neml.history
2 changes: 1 addition & 1 deletion pybind11
Submodule pybind11 updated 137 files
22 changes: 16 additions & 6 deletions src/cp/batch.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "cp/batch.h"

#include <cstdio>

#ifdef USE_OMP
#include <omp.h>
#endif
Expand All @@ -24,16 +26,24 @@ void evaluate_crystal_batch(SingleCrystalModel & model, size_t n,
omp_set_num_threads(nthreads);
#endif

size_t error_count = 0;
#ifdef USE_OMP
#pragma omp parallel for
#pragma omp parallel for reduction(+: error_count)
#endif
for (size_t i=0; i<n; i++) {
model.update_ld_inc(&d_np1[i*6], &d_n[i*6], &w_np1[i*3], &w_n[i*3],
T_np1[i], T_n[i], t_np1, t_n, &s_np1[i*6],
&s_n[i*6], &h_np1[i*nh], &h_n[i*nh],
&A_np1[i*36], &B_np1[i*18],
u_np1[i], u_n[i], p_np1[i], p_n[i]);
try {
model.update_ld_inc(&d_np1[i*6], &d_n[i*6], &w_np1[i*3], &w_n[i*3],
T_np1[i], T_n[i], t_np1, t_n, &s_np1[i*6],
&s_n[i*6], &h_np1[i*nh], &h_n[i*nh],
&A_np1[i*36], &B_np1[i*18],
u_np1[i], u_n[i], p_np1[i], p_n[i]);
}
catch (NEMLError & e) {
++error_count;
}
}
if (error_count > 0)
throw NEMLError("Errors occurred in a parallel OpenMP region");
}

void init_history_batch(SingleCrystalModel & model, size_t n, double * const hist)
Expand Down
1 change: 0 additions & 1 deletion src/nemlerror.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ NonlinearSolverError::NonlinearSolverError(std::string msg) :

}


} // namespace neml
5 changes: 5 additions & 0 deletions src/nemlerror_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ PYBIND11_MODULE(nemlerror, m) {
py::register_exception<NEMLError>(m, "NEMLError");
py::register_exception<LinalgError>(m, "LinalgError");
py::register_exception<NonlinearSolverError>(m, "NonlinearSolverError");

py::enum_<ExceptionType>(m, "ExceptionType")
.value("NEMLError", ExceptionType::NEMLError)
.value("LinalgError", ExceptionType::LinalgError)
.value("NonlinearSolverError", ExceptionType::NonlinearSolverError);
}

} // namespace neml
4 changes: 2 additions & 2 deletions test/test_nemlmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ def test_invert(self):
self.assertTrue(np.allclose(inv_ns, inv))

def test_nonsquare(self):
self.assertRaises(RuntimeError, invert_mat, self.nonsquare)
self.assertRaises(Exception, invert_mat, self.nonsquare)

def test_nonmatrix(self):
self.assertRaises(RuntimeError, invert_mat, self.big)
self.assertRaises(Exception, invert_mat, self.big)

class TestSolve(unittest.TestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion test/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class TestErrors(unittest.TestCase):
def test_badobject(self):
with self.assertRaises(RuntimeError):
with self.assertRaises(Exception):
test = parse.parse_xml(localize("examples.xml"), "test_badobject")

def test_nomodel(self):
Expand Down

0 comments on commit 219c585

Please sign in to comment.