Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ target_include_directories( standalone_driver PRIVATE ${PROJECT_SOURCE_DIR}/test
#target_include_directories( grid_opt PRIVATE ${PROJECT_BINARY_DIR}/tests )
#target_include_directories( grid_opt PRIVATE ${PROJECT_SOURCE_DIR}/tests )

#add_executable( conv_cereal_to_hdf5 conv_cereal_to_hdf5.cxx standards.cxx basis/parse_basis.cxx )
#target_link_libraries( conv_cereal_to_hdf5 PUBLIC gauxc gauxc_catch2 Eigen3::Eigen cereal )
#target_include_directories( conv_cereal_to_hdf5 PRIVATE ${PROJECT_BINARY_DIR}/tests )
#target_include_directories( conv_cereal_to_hdf5 PRIVATE ${PROJECT_SOURCE_DIR}/tests )

add_test( NAME GAUXC_SERIAL_TEST COMMAND $<TARGET_FILE:gauxc_test> )
if( GAUXC_ENABLE_MPI )
Expand Down
34 changes: 18 additions & 16 deletions tests/collocation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,64 +37,66 @@ TEST_CASE( "Water / cc-pVDZ", "[collocation]" ) {

#ifdef GENERATE_TESTS

std::ofstream ref_data( "water_cc-pVDZ_collocation.bin", std::ios::binary );
generate_collocation_data( mol, basis, ref_data );
generate_collocation_data( mol, basis, "water_cc-pVDZ_collocation.hdf5" );

#else

std::ifstream ref_data( GAUXC_REF_DATA_PATH "/water_cc-pVDZ_collocation.bin",
std::ios::binary );
std::string ref_file = GAUXC_REF_DATA_PATH "/water_cc-pVDZ_collocation.hdf5";

#ifdef GAUXC_HAS_HOST
SECTION( "Host Eval" ) {
test_host_collocation( basis, ref_data );
test_host_collocation( basis, ref_file );
}

SECTION( "Host Eval Grad" ) {
test_host_collocation_deriv1( basis, ref_data );
test_host_collocation_deriv1( basis, ref_file );
}

SECTION( "Host Eval Hessian" ) {
test_host_collocation_deriv2( basis, ref_data );
test_host_collocation_deriv2( basis, ref_file );
}

SECTION( "Host Eval Laplacian Gradient" ) {
test_host_collocation_deriv3( basis, ref_file );
}
#endif

#ifdef GAUXC_HAS_CUDA
BasisSetMap basis_map( basis, mol );
SECTION( "CUDA Eval" ) {
test_cuda_collocation( basis, ref_data );
test_cuda_collocation( basis, ref_file );
}
SECTION( "CUDA Shell to Task Eval" ) {
test_cuda_collocation_shell_to_task( basis, basis_map, ref_data );
test_cuda_collocation_shell_to_task( basis, basis_map, ref_file );
}

SECTION( "CUDA Eval Grad" ) {
test_cuda_collocation_deriv1( basis, ref_data );
test_cuda_collocation_deriv1( basis, ref_file );
}
SECTION( "CUDA Shell to Task Eval Grad" ) {
test_cuda_collocation_shell_to_task_gradient( basis, basis_map, ref_data );
test_cuda_collocation_shell_to_task_gradient( basis, basis_map, ref_file );
}

SECTION( "CUDA Shell to Task Eval Hessian" ) {
test_cuda_collocation_shell_to_task_hessian( basis, basis_map, ref_data );
test_cuda_collocation_shell_to_task_hessian( basis, basis_map, ref_file );
}

SECTION( "CUDA Shell to Task Eval Laplacian" ) {
test_cuda_collocation_shell_to_task_laplacian( basis, basis_map, ref_data );
test_cuda_collocation_shell_to_task_laplacian( basis, basis_map, ref_file );
}

SECTION( "CUDA Shell to Task Eval Laplacian Gradient" ) {
test_cuda_collocation_shell_to_task_lapgrad( basis, basis_map, ref_data );
test_cuda_collocation_shell_to_task_lapgrad( basis, basis_map, ref_file );
}
#endif // GAUXC_HAS_CUDA

#ifdef GAUXC_HAS_HIP
SECTION( "HIP Eval" ) {
test_hip_collocation( basis, ref_data );
test_hip_collocation( basis, ref_file );
}

SECTION( "HIP Eval Grad" ) {
test_hip_collocation_deriv1( basis, ref_data );
test_hip_collocation_deriv1( basis, ref_file );
}
#endif // GAUXC_HAS_HIP

Expand Down
18 changes: 16 additions & 2 deletions tests/collocation_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using namespace GauXC;

#define MAX_NPTS_CHECK 67
#define REF_COLLOCATION_DATA_DEFINED // Guard for hdf5_test_serialization_impl.hpp

struct ref_collocation_data {
std::vector<int32_t> mask;
Expand Down Expand Up @@ -49,7 +50,20 @@ struct ref_collocation_data {

};

void check_collocation_transpose( int npts, int nbf, const double* ref_val, const double* comp_val, std::string msg = "" ) {
// Weights reference data structure
struct ref_weights_data {
Molecule mol;
std::shared_ptr<MolMeta> meta;
std::vector<XCTask> tasks_unm;
std::vector<XCTask> tasks_mod;

template <typename Archive>
void serialize( Archive& ar ) {
ar( mol, tasks_unm, tasks_mod );
}
};

inline void check_collocation_transpose( int npts, int nbf, const double* ref_val, const double* comp_val, std::string msg = "" ) {

// Check transpose
for( int i = 0; i < nbf; ++i )
Expand All @@ -60,7 +74,7 @@ void check_collocation_transpose( int npts, int nbf, const double* ref_val, cons

}

void check_collocation( int npts, int nbf, const double* ref_val, const double* comp_val ) {
inline void check_collocation( int npts, int nbf, const double* ref_val, const double* comp_val ) {

for( int i = 0; i < nbf; ++i )
for( int j = 0; j < npts; ++j ) {
Expand Down
46 changes: 21 additions & 25 deletions tests/collocation_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
#ifdef GAUXC_HAS_CUDA
#include "collocation_common.hpp"
#include "hdf5_test_serialization.hpp"
#include "hdf5_test_serialization_impl.hpp"
#include "device/common/collocation_device.hpp"
#include "device_specific/cuda_util.hpp"
#include <gauxc/basisset_map.hpp>
Expand Down Expand Up @@ -215,16 +217,12 @@ void cuda_check_collocation( const std::vector<XCDeviceTask>& tasks,



void test_cuda_collocation_masked_combined( const BasisSet<double>& basis, std::ifstream& in_file, bool grad ) {
void test_cuda_collocation_masked_combined( const BasisSet<double>& basis, const std::string& filename, bool grad ) {



std::vector<ref_collocation_data> ref_data;

{
cereal::BinaryInputArchive ar( in_file );
ar( ref_data );
}
read_collocation_data(ref_data, filename);


device_queue stream( std::make_shared<util::cuda_stream>() );
Expand Down Expand Up @@ -264,15 +262,16 @@ void test_cuda_collocation_masked_combined( const BasisSet<double>& basis, std::
}

void test_cuda_collocation( const BasisSet<double>& basis,
std::ifstream& in_file ) {
const std::string& filename ) {

test_cuda_collocation_masked_combined( basis, in_file, false );
test_cuda_collocation_masked_combined( basis, filename, false );

}

void test_cuda_collocation_deriv1( const BasisSet<double>& basis,
std::ifstream& in_file ) {
const std::string& filename ) {

test_cuda_collocation_masked_combined( basis, in_file, true );
test_cuda_collocation_masked_combined( basis, filename, true );

}

Expand All @@ -291,14 +290,11 @@ void test_cuda_collocation_deriv1( const BasisSet<double>& basis,


void test_cuda_collocation_shell_to_task( const BasisSet<double>& basis, const BasisSetMap& basis_map,
std::ifstream& in_file, bool grad, bool hess, bool lapl, bool lapl_grad) {
const std::string& filename, bool grad, bool hess, bool lapl, bool lapl_grad) {

// Load reference data
std::vector<ref_collocation_data> ref_data;
{
cereal::BinaryInputArchive ar( in_file );
ar( ref_data );
}
read_collocation_data(ref_data, filename);

// Populate base task information
device_queue stream( std::make_shared<util::cuda_stream>() );
Expand Down Expand Up @@ -435,35 +431,35 @@ void test_cuda_collocation_shell_to_task( const BasisSet<double>& basis, const


void test_cuda_collocation_shell_to_task( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_cuda_collocation_shell_to_task(basis,basis_map,in_file,false, false, false, false);
test_cuda_collocation_shell_to_task(basis,basis_map,filename,false, false, false, false);

}
void test_cuda_collocation_shell_to_task_gradient( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_cuda_collocation_shell_to_task(basis,basis_map,in_file,true, false, false, false);
test_cuda_collocation_shell_to_task(basis,basis_map,filename,true, false, false, false);

}
void test_cuda_collocation_shell_to_task_hessian( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_cuda_collocation_shell_to_task(basis,basis_map,in_file,true, true, false, false);
test_cuda_collocation_shell_to_task(basis,basis_map,filename,true, true, false, false);

}

void test_cuda_collocation_shell_to_task_laplacian( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_cuda_collocation_shell_to_task(basis,basis_map,in_file,true, false, true, false);
test_cuda_collocation_shell_to_task(basis,basis_map,filename,true, false, true, false);

}

void test_cuda_collocation_shell_to_task_lapgrad( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_cuda_collocation_shell_to_task(basis,basis_map,in_file,true, true, true, true);
test_cuda_collocation_shell_to_task(basis,basis_map,filename,true, true, true, true);

}

Expand Down
38 changes: 17 additions & 21 deletions tests/collocation_hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
#ifdef GAUXC_HAS_HIP
#include "collocation_common.hpp"
#include "hdf5_test_serialization.hpp"
#include "hdf5_test_serialization_impl.hpp"
#include "device/common/collocation_device.hpp"
#include "device_specific/hip_util.hpp"
#include <gauxc/basisset_map.hpp>
Expand Down Expand Up @@ -177,16 +179,12 @@ void hip_check_collocation( const std::vector<XCDeviceTask>& tasks,



void test_hip_collocation_masked_combined( const BasisSet<double>& basis, std::ifstream& in_file, bool grad ) {
void test_hip_collocation_masked_combined( const BasisSet<double>& basis, const std::string& filename, bool grad ) {



std::vector<ref_collocation_data> ref_data;

{
cereal::BinaryInputArchive ar( in_file );
ar( ref_data );
}
read_collocation_data(ref_data, filename);


device_queue stream( std::make_shared<util::hip_stream>() );
Expand Down Expand Up @@ -226,15 +224,16 @@ void test_hip_collocation_masked_combined( const BasisSet<double>& basis, std::i
}

void test_hip_collocation( const BasisSet<double>& basis,
std::ifstream& in_file ) {
const std::string& filename ) {

test_hip_collocation_masked_combined( basis, in_file, false );
test_hip_collocation_masked_combined( basis, filename, false );

}

void test_hip_collocation_deriv1( const BasisSet<double>& basis,
std::ifstream& in_file ) {
const std::string& filename ) {

test_hip_collocation_masked_combined( basis, in_file, true );
test_hip_collocation_masked_combined( basis, filename, true );

}

Expand All @@ -253,14 +252,11 @@ void test_hip_collocation_deriv1( const BasisSet<double>& basis,

#if 0
void test_hip_collocation_shell_to_task( const BasisSet<double>& basis, const BasisSetMap& basis_map,
std::ifstream& in_file, bool grad, bool hess) {
const std::string& filename, bool grad, bool hess) {

// Load reference data
std::vector<ref_collocation_data> ref_data;
{
cereal::BinaryInputArchive ar( in_file );
ar( ref_data );
}
read_collocation_data(ref_data, filename);

// Populate base task information
device_queue stream( std::make_shared<util::hip_stream>() );
Expand Down Expand Up @@ -389,21 +385,21 @@ void test_hip_collocation_shell_to_task( const BasisSet<double>& basis, const B


void test_hip_collocation_shell_to_task( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_hip_collocation_shell_to_task(basis,basis_map,in_file,false, false);
test_hip_collocation_shell_to_task(basis,basis_map,filename,false, false);

}
void test_hip_collocation_shell_to_task_gradient( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_hip_collocation_shell_to_task(basis,basis_map,in_file,true, false);
test_hip_collocation_shell_to_task(basis,basis_map,filename,true, false);

}
void test_hip_collocation_shell_to_task_hessian( const BasisSet<double>& basis,
const BasisSetMap& basis_map, std::ifstream& in_file) {
const BasisSetMap& basis_map, const std::string& filename) {

test_hip_collocation_shell_to_task(basis,basis_map,in_file,true, true);
test_hip_collocation_shell_to_task(basis,basis_map,filename,true, true);

}
#endif
Expand Down
Loading