Unverified Commit 12ce4238 authored by gbalduzz's avatar gbalduzz Committed by GitHub
Browse files

Merge branch 'master' into const_matrix_view

parents 7f93b249 99b884ac
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -65,8 +65,11 @@ inline cublasHandle_t getHandle(const int thread_id, const int stream_id) {

#else

// Implement SFINAE.
inline void resizeHandleContainer(int /*max_threads*/) {}

inline void resizeHandleContainer(const std::size_t max_threads) {
  if (getStreamContainer().get_max_threads() < max_threads)
    resizeStreamContainer(max_threads);
}

#endif  // DCA_HAVE_CUDA

+9 −8
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#ifndef DCA_LINALG_UTIL_STREAM_CONTAINER_HPP
#define DCA_LINALG_UTIL_STREAM_CONTAINER_HPP

#include <array>
#include <cassert>
#include <functional>
#include <vector>
@@ -26,18 +27,18 @@ namespace util {

class StreamContainer {
public:
  StreamContainer(int max_threads = 0) : streams_(max_threads * streams_per_thread_) {}
  StreamContainer(std::size_t max_threads = 0) : streams_(max_threads) {}

  int get_max_threads() const {
    return streams_.size() / streams_per_thread_;
  std::size_t get_max_threads() const {
    return streams_.size();
  }

  int get_streams_per_thread() const {
  std::size_t get_streams_per_thread() const {
    return streams_per_thread_;
  }

  void resize(const int max_threads) {
    streams_.resize(max_threads * streams_per_thread_);
    streams_.resize(max_threads);
  }

  StreamContainer(const StreamContainer&) = delete;
@@ -49,7 +50,7 @@ public:
  CudaStream& operator()(int thread_id, int stream_id) {
    assert(thread_id >= 0 && thread_id < get_max_threads());
    assert(stream_id >= 0 && stream_id < streams_per_thread_);
    return streams_[stream_id + streams_per_thread_ * thread_id];
    return streams_[thread_id][stream_id];
  }

  // Synchronizes the 'stream_id'-th stream associated with thread 'thread_id'.
@@ -60,8 +61,8 @@ public:
  }

private:
  constexpr static int streams_per_thread_ = 2;
  std::vector<CudaStream> streams_;
  constexpr static std::size_t streams_per_thread_ = 2;
  std::vector<std::array<CudaStream, streams_per_thread_>> streams_;
};

}  // namespace util
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ void general_interaction<parameters_type>::set_vertex(

  // Get a random pair of correlated spin-orbitals.
  const int pos = rng() * correlated_orbitals.size();
  // This is instead of crashing on segv when module is unknown.
  // \todo catch earlier in release as well.
  assert( pos < correlated_orbitals.size() && "It is likely you have specified an unknown model" );
  const int lin_ind = correlated_orbitals[pos];

  std::array<int, 6> sub_ind;  // [0]=b1, [1]=s1, [2]=b2, [3]=s2, [4]=r1, [5]=r2
@@ -118,6 +121,7 @@ std::vector<int> general_interaction<parameters_type>::make_correlated_orbitals(
        for (auto b_j : interacting_orbitals) {
          for (int s_i = 0; s_i < SpinDmn::dmn_size(); ++s_i) {
            for (auto b_i : interacting_orbitals) {
              // This 1.e-3 seems like a very magic number!
              if (std::abs(H_interaction(b_i, s_i, b_j, s_j, delta_r)) > 1.e-3) {
                int linear_index = get_spin_orbital_pair_domain<BandDmn, SpinDmn, RDmn>()(
                    b_i, s_i, b_j, s_j, r_i, r_j);