Trong mã của tôi, tôi có vòng lặp trong đó tôi xây dựng và hơn hệ thống tuyến tính quyết tâm và cố gắng giải quyết nó:Có phải chuỗi armadillo giải quyết() an toàn không?
#pragma omp parallel for
for (int i = 0; i < n[0]+1; i++) {
for (int j = 0; j < n[1]+1; j++) {
for (int k = 0; k < n[2]+1; k++) {
arma::mat A(max_points, 2);
arma::mat y(max_points, 1);
// initialize A and y
arma::vec solution = solve(A,y);
}
}
}
Đôi khi, khá ngẫu nhiên bị treo chương trình hoặc các kết quả trong các vector giải pháp là NaN. Và nếu tôi đặt điều này:
arma::vec solution;
#pragma omp critical
{
solution = solve(weights*A,weights*y);
}
thì vấn đề này dường như không còn xảy ra nữa.
Khi nó bị treo, nó làm như vậy bởi vì một số chủ đề đang chờ đợi ở hàng rào OpenMP:
Thread 2 (Thread 0x7fe4325a5700 (LWP 39839)):
#0 0x00007fe44d3c2084 in gomp_team_barrier_wait_end() from /usr/lib64/gcc-4.9.2/lib64/gcc/x86_64-redhat-linux-gnu/4.9.2/libgomp.so.1
#1 0x00007fe44d3bf8c2 in gomp_thread_start() at ../.././libgomp/team.c:118
#2 0x0000003f64607851 in start_thread() from /lib64/libpthread.so.0
#3 0x0000003f642e890d in clone() from /lib64/libc.so.6
Và các chủ đề khác đang bị mắc kẹt bên trong Armadillo:
Thread 1 (Thread 0x7fe44afe2e60 (LWP 39800)):
#0 0x0000003ee541f748 in dscal_() from /usr/lib64/libblas.so.3
#1 0x00007fe44c0d3666 in dlarfp_() from /usr/lib64/atlas/liblapack.so.3
#2 0x00007fe44c058736 in dgelq2_() from /usr/lib64/atlas/liblapack.so.3
#3 0x00007fe44c058ad9 in dgelqf_() from /usr/lib64/atlas/liblapack.so.3
#4 0x00007fe44c059a32 in dgels_() from /usr/lib64/atlas/liblapack.so.3
#5 0x00007fe44f09fb3d in bool arma::auxlib::solve_ud<double, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> >(arma::Mat<double>&, arma::Mat<double>&, arma::Base<double, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> > const&)() at /usr/include/armadillo_bits/lapack_wrapper.hpp:677
#6 0x00007fe44f0a0f87 in arma::Col<double>::Col<arma::Glue<arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times>, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times>, arma::glue_solve> >(arma::Base<double, arma::Glue<arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times>, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times>, arma::glue_solve> > const&)()
at /usr/include/armadillo_bits/glue_solve_meat.hpp:39
Như bạn có thể nhìn thấy từ stacktrace phiên bản Armadillo của tôi sử dụng bản đồ. Và theo atlas tài liệu này có vẻ là chủ đề an toàn: ftp://lsec.cc.ac.cn/netlib/atlas/faq.html#tsafe
Cập nhật 9/11/2015
cuối cùng tôi đã có một số thời gian để chạy thử nghiệm nhiều hơn, dựa trên những gợi ý của Vladimir F.
Khi tôi biên dịch armadillo với BLAS của ATLAS, tôi vẫn có thể tái sản xuất sau đó bị treo và các NaN. Khi nó bị treo, điều duy nhất mà thay đổi trong stacktrace là cuộc gọi đến BLAS:
#0 0x0000003fa8054718 in [email protected]() from /usr/lib64/atlas/libatlas.so.3
#1 0x0000003fb05e7666 in dlarfp_() from /usr/lib64/atlas/liblapack.so.3
#2 0x0000003fb0576a61 in dgeqr2_() from /usr/lib64/atlas/liblapack.so.3
#3 0x0000003fb0576e06 in dgeqrf_() from /usr/lib64/atlas/liblapack.so.3
#4 0x0000003fb056d7d1 in dgels_() from /usr/lib64/atlas/liblapack.so.3
#5 0x00007ff8f3de4c34 in void arma::lapack::gels<double>(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, int*)() at /usr/include/armadillo_bits/lapack_wrapper.hpp:677
#6 0x00007ff8f3de1787 in bool arma::auxlib::solve_od<double, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> >(arma::Mat<double>&, arma::Mat<double>&, arma::Base<double, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> > const&)() at /usr/include/armadillo_bits/auxlib_meat.hpp:3434
Biên soạn không ATLAS, chỉ với netlib BLAS và LAPACK, tôi đã có thể tái tạo các Nans nhưng không phải là bị treo.
Trong cả hai trường hợp, xung quanh solve()
với #pragma
OMP quan trọng tôi không có vấn đề gì cả
Là /usr/lib64/libblas.so.3 một phần của tập bản đồ? Tại sao nó không nằm trong/usr/lib64/atlas? –
Không, trong mở nó là một phần của gói liblas3 và trong redhat nó là một phần của gói blas. – maxdebayser
Sau đó, bạn không thể sử dụng bất kỳ sự bảo đảm nào của ATLAS khi bạn sử dụng BLAS mặc định. –