Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjharrison committed Feb 2, 2024
1 parent b8e6977 commit ba1e741
Show file tree
Hide file tree
Showing 33 changed files with 191 additions and 193 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

## I know this is obnoxious but I don't know any other way to keep
## things clean. Make the build verbose so that people see the warning
## messages and fix the issues --- some of them are real
#set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")

# safety net for dev workflow: accidental install will not affect FindOrFetch*
if (NOT DEFINED CACHE{CMAKE_FIND_NO_INSTALL_PREFIX})
set(CMAKE_FIND_NO_INSTALL_PREFIX ON CACHE BOOL "Whether find_* commands will search CMAKE_INSTALL_PREFIX and CMAKE_STAGING_PREFIX; see https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_NO_INSTALL_PREFIX.html#variable:CMAKE_FIND_NO_INSTALL_PREFIX")
Expand Down Expand Up @@ -110,7 +115,21 @@ option(ENABLE_PAPI "Enables use of PAPI" OFF)
option(ENABLE_LIBXC "Enables use of the libxc library of density functionals" ON)
option(ENABLE_PCM "Enables use of the polarizable continuum model library" ON)

####### preferred task backend
set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
check_cxx_source_compiles(
"
namespace madness {
template <typename T>
void mTxmq(long dimi, long dimj, long dimk,
T* __restrict__ c, const T* a, const T* b, long ldb=-1);
template <>
void mTxmq(long dimi, long dimj, long dimk, double* __restrict__ c, const double* a, const double* b, long ldb);
}
int main() { double a[1], b[1], c[1]; madness::mTxmq(1,1,1,c,a,b,1); return 0; }
" HAVE_MTXMQ)

####### preferred task backend
set(MADNESS_TASK_VALID_BACKENDS Pthreads TBB PaRSEC)
set(MADNESS_TASK_BACKEND Pthreads CACHE STRING "The backend to use for dispatching tasks")
set_property(CACHE MADNESS_TASK_BACKEND PROPERTY STRINGS ${MADNESS_TASK_VALID_BACKENDS})
Expand Down Expand Up @@ -358,7 +377,7 @@ if (NOT DEFINED MADNESS_CONFIGURATION_DATE)
set(MADNESS_CONFIGURATION_DATE "${madness_configuration_date}" CACHE INTERNAL "")
endif (NOT DEFINED MADNESS_CONFIGURATION_DATE)

set(MAD_BIND_DEFAULT "-1 -1 -1" CACHE STRING "The default binding for threads")
set(MAD_BIND_DEFAULT "ON" CACHE STRING "The default binding for threads")

# Check if the target platform is CRAY XE
check_cxx_source_compiles(
Expand Down
1 change: 1 addition & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#endif

/* Define MADNESS has access to the library. */
#cmakedefine HAVE_MTXMQ 1
#cmakedefine HAVE_ACML 1
#cmakedefine HAVE_INTEL_TBB 1
#cmakedefine MADNESS_CAN_USE_TBB_PRIORITY 1
Expand Down
8 changes: 4 additions & 4 deletions src/apps/dirac/DF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ GradBSHOperator_Joel(World& world,
// Then need to truncate coeff and expnt into new Tensors
int rank = coeff.dim(0);
double Cdelta = 0.0;
double max_kept;
int max_j;
//double max_kept;
int max_j=0;
for(int j = 0; j < rank; j++){
if(expnt[j] > max_expnt){
Cdelta += coeff[j]*std::pow(constants::pi/expnt[j],1.5);
}
else{
max_kept = expnt[j];
//max_kept = expnt[j];
max_j = j;
break;
}
Expand Down Expand Up @@ -1102,7 +1102,7 @@ void apply_BSH_new(World& world, Fcwf& Vpsi, double& eps, double& small, double&
double myc = 137.0359895; //speed of light
double c2 = myc*myc; //speed of light squared
std::complex<double> myi(0,1); //imaginary number i
std::complex<double> ic = myi*myc; //i*c
//std::complex<double> ic = myi*myc; //i*c

//calculate exponent for equivalent BSH operator
double mu = std::sqrt(-(2*eps*c2+eps*eps)/c2);
Expand Down
12 changes: 6 additions & 6 deletions src/apps/dirac/DFdriver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
static inline int file_exists(const char * inpname)
{
struct stat buffer;
int rc = stat(inpname, &buffer);
return (rc==0);
}
// static inline int file_exists(const char * inpname)
// {
// struct stat buffer;
// int rc = stat(inpname, &buffer);
// return (rc==0);
// }
#endif

int main(int argc, char **argv) {
Expand Down
6 changes: 3 additions & 3 deletions src/apps/dirac/InitParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace madness{

//read in what's in the archive. See SCF::save_mos for how these archives are stored
archive::ParallelInputArchive input(world, filename.c_str());
unsigned int version;
unsigned int version=0;
std::string xc;
std::string localize_method;

Expand Down Expand Up @@ -113,7 +113,7 @@ namespace madness{
complex_derivative_3d Dx(world,0);
complex_derivative_3d Dy(world,1);
complex_derivative_3d Dz(world,2);
double myc = 137.0359895; //speed of light in atomic units
//double myc = 137.0359895; //speed of light in atomic units
std::complex<double> myi(0,1);
if(spinrestricted){
//If the calculation was spin-restricted in moldft, then we only have "spin-up" orbitals
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace madness{

if(!Krestricted){
// Read in beta quantities
unsigned int num_betas;
unsigned int num_betas=0;
input & num_betas;

Tensor<double> beta_energies;
Expand Down
4 changes: 2 additions & 2 deletions src/madness/chem/CCStructures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ MacroTaskMp2ConstantPart::operator() (const std::vector<CCPair>& pair, const std
const std::vector<std::string>& argument) const {
World& world = mo_ket[0].world();
resultT result = zero_functions_compressed<double, 6>(world, pair.size());
for (int i = 0; i < pair.size(); i++) {
for (size_t i = 0; i < pair.size(); i++) {
result[i] = CCPotentials::make_constant_part_mp2_macrotask(world, pair[i], mo_ket, mo_bra, parameters,
Rsquare, U1, argument);
}
Expand All @@ -651,7 +651,7 @@ MacroTaskMp2UpdatePair::operator() (const std::vector<CCPair> &pair,
World& world = mo_ket[0].world();
resultT result = zero_functions_compressed<double, 6>(world, pair.size());

for (int i = 0; i < pair.size(); i++) {
for (size_t i = 0; i < pair.size(); i++) {
//(i, j) -> j*(j+1) + i
result[i] = CCPotentials::update_pair_mp2_macrotask(world, pair[i], parameters, all_coords_vec, mo_ket,
mo_bra, U1, U2, mp2_coupling[i]);
Expand Down
6 changes: 3 additions & 3 deletions src/madness/chem/CCStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ struct PairVectorMap {
void print(const std::string msg="PairVectorMap") const {
madness::print(msg);
madness::print("vector element <-> pair index");
for (int i=0; i<map.size(); ++i) {
for (size_t i=0; i<map.size(); ++i) {
madness::print(i, " <-> ",map[i]);
}
}
Expand Down Expand Up @@ -1106,7 +1106,7 @@ class MacroTaskMp2ConstantPart : public MacroTaskOperationBase {
partitionT do_partitioning(const std::size_t& vsize1, const std::size_t& vsize2,
const std::string policy) const override {
partitionT p;
for (int i = 0; i < vsize1; i++) {
for (size_t i = 0; i < vsize1; i++) {
Batch batch(Batch_1D(i,i+1), Batch_1D(i,i+1));
p.push_back(std::make_pair(batch,1.0));
}
Expand Down Expand Up @@ -1146,7 +1146,7 @@ class MacroTaskMp2UpdatePair : public MacroTaskOperationBase {
partitionT do_partitioning(const std::size_t& vsize1, const std::size_t& vsize2,
const std::string policy) const override {
partitionT p;
for (int i = 0; i < vsize1; i++) {
for (size_t i = 0; i < vsize1; i++) {
Batch batch(Batch_1D(i, i+1), Batch_1D(i, i+1), Batch_1D(i,i+1));
p.push_back(std::make_pair(batch, 1.0));
}
Expand Down
2 changes: 1 addition & 1 deletion src/madness/chem/MolecularOrbitals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void MolecularOrbitals<T,NDIM>::print_cubefiles(const std::string name, const st
if (get_mos().size()==0) return;
if constexpr (std::is_same<T,double_complex>::value) return;
World& world=get_mos().front().world();
for (int i=0; i<get_mos().size(); ++i) {
for (size_t i=0; i<get_mos().size(); ++i) {
std::string filename=name+"_"+std::to_string(i)+".cube";
if constexpr (std::is_same<T,double>::value)
plot_cubefile<3>(world,get_mos()[i],filename,cubefile_header);
Expand Down
6 changes: 3 additions & 3 deletions src/madness/chem/MolecularOrbitals.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MolecularOrbitals : public archive::ParallelSerializableObject {
auto slices = convert_set_to_slice(localize_sets);
auto s=slices[iset];
MolecularOrbitals result;
MADNESS_CHECK(mo.size()>=s.end+1);
MADNESS_CHECK(mo.size()>=size_t(s.end+1));
// result.mo.assign(mo.begin()+s.start,mo.begin()+s.end+1);
for (int i=s.start; i<s.end+1; ++i) result.mo.push_back(copy(mo[i]));
if (eps.size()>0) result.eps=copy(eps(s));
Expand Down Expand Up @@ -121,7 +121,7 @@ class MolecularOrbitals : public archive::ParallelSerializableObject {
set_all_orbitals_occupied();
std::size_t nmo = mo.size();
std::vector<int> set = std::vector<int>(static_cast<size_t>(nmo), 0);
for (int i = 1; i < nmo; ++i) {
for (size_t i = 1; i < nmo; ++i) {
set[i] = set[i - 1];
// Only the new/boys localizers can tolerate not separating out the core orbitals
if (eps(i) - eps(i - 1) > bandwidth || get_occ()(i) != 1.0) ++(set[i]);
Expand All @@ -133,7 +133,7 @@ class MolecularOrbitals : public archive::ParallelSerializableObject {
static std::vector<Slice> convert_set_to_slice(const std::vector<int>& localized_set) {
std::vector<Slice> blocks;
long ilo=0;
for (int i=1; i<localized_set.size(); ++i) {
for (size_t i=1; i<localized_set.size(); ++i) {
if (not (localized_set[i]==localized_set[i-1])) {
blocks.push_back(Slice(ilo, i-1));
ilo=i;
Expand Down
4 changes: 2 additions & 2 deletions src/madness/chem/ccpairfunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ double CCPairFunction::inner_internal(const CCPairFunction& other, const real_fu
MADNESS_EXCEPTION(("6D Overlap with operatortype " + assign_name(f2.get_operator().type()) + " not supported").c_str(), 1);
}
}
for (int i=0; i<a.size(); ++i) {
for (size_t i=0; i<a.size(); ++i) {
auto x=a[i];
auto y=b[i];
real_function_6d opxy;
Expand Down Expand Up @@ -355,4 +355,4 @@ std::vector<CCPairFunction> apply(const ProjectorBase& projector, const std::vec
};


} // namespace madness
} // namespace madness
3 changes: 2 additions & 1 deletion src/madness/chem/exchangeoperator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Exchange<T, NDIM>::ExchangeImpl::MacroTaskExchangeSimple::compute_offdiagonal_ba
}


template
template
class Exchange<double_complex, 3>::ExchangeImpl;

template
Expand All @@ -327,5 +327,6 @@ template<> volatile std::list<detail::PendingMsg> WorldObject<WorldContainerImpl
template<> Spinlock WorldObject<WorldContainerImpl<long, std::vector<unsigned char>, madness::Hash<long> > >::pending_mutex(
0);

Exchange<double,3>::ExchangeImpl junkjunkjunk(World& world, const SCF *calc, const int ispin) {return Exchange<double,3>::ExchangeImpl(world, calc, ispin);}

} /* namespace madness */
2 changes: 1 addition & 1 deletion src/madness/chem/localizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ MolecularOrbitals<T, NDIM> Localizer::localize(const MolecularOrbitals<T, NDIM>&
Tensor<T> U(nmo, nmo);
Tensor<T> fnew(nmo, nmo);
if (enforce_core_valence_separation) {
MADNESS_CHECK(Fock.dim(0) == mo_in.get_mos().size());
MADNESS_CHECK(size_t(Fock.dim(0)) == mo_in.get_mos().size());

MolecularOrbitals<T, NDIM> mo_cv_separated = mo_in;
Tensor<double> U1 = compute_core_valence_separation_transformation_matrix(world, mo_in, Fock);
Expand Down
2 changes: 1 addition & 1 deletion src/madness/chem/molecule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void Molecule::read_xyz(const std::string filename) {
add_atom(xx,yy,zz,qq,atn,psat);
if (current_line==natom_expected+2) break;
}
MADNESS_CHECK(natom_expected==natom());
MADNESS_CHECK(size_t(natom_expected)==natom());
update_rcut_with_eprec(parameters.eprec());
}

Expand Down
2 changes: 1 addition & 1 deletion src/madness/chem/nemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class NemoBase : public MolecularOptimizationTargetInterface {
//double ke3_real=0.0;
//double ke3_imag=0.0;

for (int axis = 0; axis < NDIM; axis++) {
for (size_t axis = 0; axis < NDIM; axis++) {
real_derivative_3d D = free_space_derivative<double, NDIM>(world, axis);
const std::vector<Function<T,NDIM> > dnemo = apply(world, D, nemo);

Expand Down
2 changes: 1 addition & 1 deletion src/madness/chem/oep.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class OEP : public Nemo {

// get \nabla nemo
std::vector<vecfuncT> grad_nemo(nemo.size());
for (long i = 0; i < nemo.size(); i++) {
for (size_t i = 0; i < nemo.size(); i++) {
vecfuncT nemo_copy=copy(world,nemo);
refine(world,nemo_copy);

Expand Down
4 changes: 2 additions & 2 deletions src/madness/chem/projector.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ namespace madness {
/// @return the projected function
template<std::size_t KDIM>
typename std::enable_if<KDIM==2*NDIM, Function<T,KDIM> >::type
operator()(const Function<T,KDIM>& f, size_t particle1=-1) const {
operator()(const Function<T,KDIM>& f, size_t particle1=size_t(-1)) const {
Function<T,KDIM> result = FunctionFactory<T,KDIM>(f.world());
if (particle1==-1) particle1=particle;
if (particle1==size_t(-1)) particle1=particle;
MADNESS_ASSERT(particle1 == 1 or particle1 == 2);
for (size_t i = 0; i < mo_ket_.size(); i++) {
Function<T,NDIM> tmp1 = mo_ket_[i];
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(BUILD_TESTING)
set(MRA_TEST_SOURCES testbsh.cc testproj.cc
testpdiff.cc testdiff1Db.cc testgconv.cc testopdir.cc testinnerext.cc
testgaxpyext.cc testvmra.cc, test_vectormacrotask.cc test_cloud.cc test_tree_state.cc
test_macrotaskpartitioner.cc test_QCCalculationParametersBase.cc)
test_macrotaskpartitioner.cc test_QCCalculationParametersBase.cc testjon.cc)
add_unittests(mra "${MRA_TEST_SOURCES}" "MADmra;MADgtest" "unittests;short")
set(MRA_SEPOP_TEST_SOURCES testsuite.cc
testper.cc)
Expand Down
4 changes: 2 additions & 2 deletions src/madness/mra/QCCalculationParametersBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::string QCCalculationParametersBase::print_to_string(bool non_defaults_only)
const QCParameter& param=std::get<2>(p);
if (non_defaults_only and (param.precedence==QCParameter::def)) continue;
ss << param.print_line(std::get<1>(p));
if (++counter<list.size()) ss << std::endl; // no newline at the very end
if (++counter<int(list.size())) ss << std::endl; // no newline at the very end
}
return ss.str();
}
Expand Down Expand Up @@ -195,4 +195,4 @@ void QCCalculationParametersBase::read_internal(World& world, std::string& filec
const QCCalculationParametersBase& p2) {
return !(p1 == p2);
}
} /* namespace madness */
} /* namespace madness */
2 changes: 1 addition & 1 deletion src/madness/mra/QCCalculationParametersBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ struct QCParameter {
}

std::string result;
for (int i=0; i<commentlines.size(); ++i) {
for (size_t i=0; i<commentlines.size(); ++i) {
if (i==0) result=keyval+fill_right(40,commentlines[i])+allowed_val;
else result+="\n"+empty_keyval+commentlines[i];
}
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/funcimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace madness {

explicit
FunctionNode(const coeffT& coeff, double norm_tree, double snorm, double dnorm, bool has_children) :
_coeffs(coeff), _norm_tree(norm_tree), _has_children(has_children), snorm(snorm), dnorm(dnorm) {
_coeffs(coeff), _norm_tree(norm_tree), _has_children(has_children), dnorm(dnorm), snorm(snorm) {
}

FunctionNode(const FunctionNode<T, NDIM>& other) {
Expand Down
4 changes: 2 additions & 2 deletions src/madness/mra/macrotaskpartitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Batch_1D {
/// given vector v, copy vector elements of v_batch into vector
template<typename vecT>
vecT insert_batch(vecT v, const vecT& v_batch) const {
MADNESS_CHECK(v_batch.size()==this->size() or this->is_full_size());
MADNESS_CHECK(v_batch.size()==size_t(this->size()) or this->is_full_size());
std::copy(v_batch.begin(), v_batch.end(), v.begin()+begin);
return v;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ class MacroTaskPartitioner {
if (policy == "guided") {
long begin = 0;
long end = 0;
while (end < vsize) {
while (end < long(vsize)) {
end += std::min(max_batch_size, std::max(min_batch_size, ((vsize - end) / nsubworld)));
end = std::min(end, long(vsize));
Batch batch(Batch_1D(begin, end),Batch_1D(begin,end));
Expand Down
2 changes: 1 addition & 1 deletion src/madness/mra/macrotaskq.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MacroTaskQ : public WorldObject< MacroTaskQ> {
void run_all(MacroTaskBase::taskqT vtask=MacroTaskBase::taskqT()) {

for (const auto& t : vtask) if (universe.rank()==0) t->set_waiting();
for (int i=0; i<vtask.size(); ++i) add_replicated_task(vtask[i]);
for (size_t i=0; i<vtask.size(); ++i) add_replicated_task(vtask[i]);
if (printdebug()) print_taskq();

cloud.replicate();
Expand Down
Loading

0 comments on commit ba1e741

Please sign in to comment.