Skip to content

Commit

Permalink
trying to get a clean compile with clang++
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjharrison committed Dec 29, 2023
1 parent 53219bc commit 34c5b77
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 42 deletions.
32 changes: 15 additions & 17 deletions src/madness/mra/funcimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ namespace madness {
/// Accumulate inplace and if necessary connect node to parent
void accumulate2(const tensorT& t, const typename FunctionNode<T,NDIM>::dcT& c,
const Key<NDIM>& key) {
double cpu0=cpu_time();
// double cpu0=cpu_time();
if (has_coeff()) {
MADNESS_ASSERT(coeff().is_full_tensor());
// if (coeff().type==TT_FULL) {
Expand All @@ -397,14 +397,13 @@ namespace madness {
const_cast<dcT&>(c).task(parent, &FunctionNode<T,NDIM>::set_has_children_recursive, c, parent);
}
}
double cpu1=cpu_time();
//double cpu1=cpu_time();
}


/// Accumulate inplace and if necessary connect node to parent
void accumulate(const coeffT& t, const typename FunctionNode<T,NDIM>::dcT& c,
const Key<NDIM>& key, const TensorArgs& args) {
double cpu0=cpu_time();
if (has_coeff()) {
coeff().add_SVD(t,args.thresh);
if (buffer.rank()<coeff().rank()) {
Expand All @@ -429,7 +428,6 @@ namespace madness {
const_cast<dcT&>(c).task(parent, &FunctionNode<T,NDIM>::set_has_children_recursive, c, parent);
}
}
double cpu1=cpu_time();
}

void consolidate_buffer(const TensorArgs& args) {
Expand Down Expand Up @@ -4107,9 +4105,10 @@ namespace madness {
Key<LDIM> key1, key2;
key.break_apart(key1,key2);

bool printme=(int(key.translation()[0])==int(std::pow(key.level(),2)/2)) and
(int(key.translation()[1])==int(std::pow(key.level(),2)/2)) and
(int(key.translation()[2])==int(std::pow(key.level(),2)/2));
// bool printme=(int(key.translation()[0])==int(std::pow(key.level(),2)/2)) and
// (int(key.translation()[1])==int(std::pow(key.level(),2)/2)) and
// (int(key.translation()[2])==int(std::pow(key.level(),2)/2));

// printme=false;

// get/make all coefficients
Expand Down Expand Up @@ -5561,9 +5560,9 @@ namespace madness {
const std::array<int, CDIM> v1, const std::array<int, CDIM> v2) {

typedef std::multimap<Key<NDIM>, std::list<Key<CDIM>>> contractionmapT;
double wall_get_lists=0.0;
double wall_recur=0.0;
double wall_contract=0.0;
//double wall_get_lists=0.0;
//double wall_recur=0.0;
//double wall_contract=0.0;
std::size_t nmax=FunctionDefaults<CDIM>::get_max_refine_level();
const double thresh=FunctionDefaults<NDIM>::get_thresh();

Expand All @@ -5578,13 +5577,13 @@ namespace madness {
for (int n=0; n<nmax; ++n) {

// list of nodes with d coefficients (and their parents)
double wall0 = wall_time();
//double wall0 = wall_time();
auto [g_ijlist, g_jlist] = g.get_contraction_node_lists(n, v1);
auto [h_ijlist, h_jlist] = h.get_contraction_node_lists(n, v2);
if ((g_ijlist.size() == 0) and (h_ijlist.size() == 0)) break;
double wall1 = wall_time();
wall_get_lists += (wall1 - wall0);
wall0 = wall1;
//double wall1 = wall_time();
//wall_get_lists += (wall1 - wall0);
//wall0 = wall1;
// print("g_jlist");
// for (const auto& kv : g_jlist) print(kv.first,kv.second);
// print("h_jlist");
Expand Down Expand Up @@ -5624,8 +5623,8 @@ namespace madness {
elem.second.sort();
elem.second.unique();
}
wall1 = wall_time();
wall_recur += (wall1 - wall0);
//wall1 = wall_time();
//wall_recur += (wall1 - wall0);
// if (n==2) {
// print("contraction map for n=", n);
// print_map(contraction_map);
Expand Down Expand Up @@ -5719,7 +5718,6 @@ namespace madness {
bool this_first, const double thresh) {

std::multimap<Key<FDIM>, std::list<Key<CDIM>>> contraction_map;
std::size_t level=key.level();

// fast return if the other function has no d coeffs
if (j_other_list.empty()) return contraction_map;
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/macrotaskpartitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ class Batch_1D {
class Batch {
public:
friend class MacroTaskPartitioner;
Batch_1D result;
std::vector<Batch_1D> input;
Batch_1D result;

Batch() {}
Batch(const Batch& other) {
Expand Down
14 changes: 11 additions & 3 deletions src/madness/mra/macrotaskq.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ class MacroTaskQ : public WorldObject< MacroTaskQ> {

/// create an empty taskq and initialize the subworlds
MacroTaskQ(World& universe, int nworld, const long printlevel=0)
: universe(universe), WorldObject<MacroTaskQ>(universe), taskq(), cloud(universe), printlevel(printlevel),
nsubworld(nworld) {
: WorldObject<MacroTaskQ>(universe)
, universe(universe)
, taskq()
, printlevel(printlevel)
, nsubworld(nworld)
, cloud(universe)
{

subworld_ptr=create_worlds(universe,nworld);
this->process_pending();
Expand Down Expand Up @@ -241,7 +246,10 @@ class MacroTaskQ : public WorldObject< MacroTaskQ> {
/// scheduler is located on universe.rank==0
long get_scheduled_task_number(World& subworld) {
long number=0;
if (subworld.rank()==0) number=this->send(ProcessID(0), &MacroTaskQ::get_scheduled_task_number_local);
if (subworld.rank()==0) {
Future<long> r = this->send(ProcessID(0), &MacroTaskQ::get_scheduled_task_number_local);
number=r.get();
}
subworld.gop.broadcast_serializable(number, 0);
subworld.gop.fence();
return number;
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/mra.h
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ namespace madness {
result.get_impl()->apply(op, *f.get_impl(), fence);

} else { // general version for higher dimension
bool print_timings=false;
//bool print_timings=false;
Function<TENSOR_RESULT_TYPE(typename opT::opT,R), NDIM> r1;

result.set_impl(f, false);
Expand Down
6 changes: 2 additions & 4 deletions src/madness/tensor/RandomizedMatrixDecomposition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ template<typename T>
Tensor<T> RandomizedMatrixDecomposition<T>::compute_range(const Tensor<T>& tensor,
const double& eps, std::array<long,2> vectordim) {

typedef typename Tensor<T>::scalar_type scalar_type;
//typedef typename Tensor<T>::scalar_type scalar_type;

// fast return if possible
range=Tensor<T>(0l,0l);
if (tensor.normf()<eps) return range;

const Tensor<T> matrix=resize_to_matrix(tensor,vectordim);
const long m=matrix.dim(0);
const long n=matrix.dim(1);

maxrank=std::min(maxrank,matrix.dim(0));

Expand Down Expand Up @@ -86,7 +84,7 @@ Tensor<T> RandomizedMatrixDecomposition<T>::do_compute_range(const Y_former& Yfo
template<typename T>
Tensor<T> RandomizedMatrixDecomposition<T>::compute_range(const Tensor<T>& columnspace,
const Tensor<T>& rowspace, const double& eps) {
typedef typename Tensor<T>::scalar_type scalar_type;
//typedef typename Tensor<T>::scalar_type scalar_type;

// fast return if possible
Tensor<T> Q(0l,0l);
Expand Down
6 changes: 3 additions & 3 deletions src/madness/tensor/RandomizedMatrixDecomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ class RandomizedMatrixDecomposition {

private:

/// oversampling parameter
long oversampling=10;

/// maximum rank to abort the decomposition
long maxrank=LONG_MAX;

/// oversampling parameter
long oversampling=10;

/// the range that spans the input matrix
Tensor<T> range=Tensor<T>(0l,0l);

Expand Down
1 change: 0 additions & 1 deletion src/madness/tensor/SVDTensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ void SVDTensor<T>::orthonormalize_random(const double& eps) {

long maxrank=std::min(this->kVec(0),this->kVec(1));

double wall0=wall_time();
RandomizedMatrixDecomposition<T> rmd=RMDFactory().maxrank(maxrank);
Tensor<T> scr=this->make_left_vector_with_weights();
Tensor<T> Q=rmd.compute_range(scr,this->flat_vector(1),eps*0.1);
Expand Down
21 changes: 14 additions & 7 deletions src/madness/tensor/clapack_fortran.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,20 @@ extern "C"
real4* work, integer* lwork, integer* info,
char_len jobzlen, char_len uplo_len);

// extern "C"
// void dggev_(const char* jobz, const char* uplo, integer *n,
// real8* a, integer* lda, real8* b, integer* ldb,
// real8* alphar, real8* alphai, real8* beta,
// real8* vl, integer* ldvl, real8* vr, integer* ldvr,
// real8* work, integer* lwork, integer* info,
// char_len jobzlen, char_len uplo_len);
extern "C"
void dggev_(const char* jobl, const char* jobr, integer *n,
real8 *a, integer *lda, real8 *b, integer *ldb,
real8 *w_real, real8 *w_imag, real8 *beta,
real8 *vl, integer *ldvl, real8 *vr, integer *ldvr,
real8 *work, integer *lwork, integer *info,
char_len jobzlen, char_len uplo_len);

// void dggev_(const char* jobz, const char* uplo, integer *n,
// real8* a, integer* lda, real8* b, integer* ldb,
// real8* alphar, real8* alphai, real8* beta,
// real8* vl, integer* ldvl, real8* vr, integer* ldvr,
// real8* work, integer* lwork, integer* info,
// char_len jobzlen, char_len uplo_len);

extern "C"
void cggev_(const char* jobz, const char* uplo, integer *n,
Expand Down
6 changes: 2 additions & 4 deletions src/madness/tensor/lapack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,18 +509,16 @@ STATIC inline void dggev_(const char* jobl, const char* jobr, integer *n,
#endif
}

#if MADNESS_LINALG_USE_LAPACKE
STATIC inline void dggev_(const char* jobl, const char* jobr, integer *n,
real8 *a, integer *lda, real8 *b, integer *ldb,
real8 *w_real, real8 *w_imag, real8 *beta,
real8 *vl, integer *ldvl, real8 *vr, integer *ldvr,
real8 *work, integer *lwork, integer *info,
char_len jobzlen, char_len uplo_len) {
#if MADNESS_LINALG_USE_LAPACKE
dggev_(jobl, jobr, n, a, lda, b, ldb, w_real, w_imag, beta, vl, ldvl, vr, ldvr, work, lwork, info );
#else
dggev_(jobl, jobr, n, a, lda, b, ldb, w_real, w_imag, beta, vl, ldvl, vr, ldvr, work, lwork, info, jobzlen, uplo_len);
#endif
}
#endif

STATIC inline void dggev_(const char* jobl, const char* jobr, integer *n,
complex_real4 *a, integer *lda, complex_real4 *b, integer *ldb,
Expand Down
2 changes: 1 addition & 1 deletion src/madness/world/cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ class Cloud {
template<typename T> using is_world_constructible = std::is_constructible<T, World &>;

struct cloudtimer {
World& world;
double cpu0;
std::atomic<long> &rtime;
World& world;

cloudtimer(World& world, std::atomic<long> &readtime) : world(world), cpu0(cpu_time()), rtime(readtime) {}

Expand Down

0 comments on commit 34c5b77

Please sign in to comment.