Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions cmake/gauxc-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ if( GAUXC_HAS_CUDA )
endif()
endif()

if( GAUXC_HAS_HIP )
enable_language( HIP )
find_dependency( hip )
find_dependency( hipblas )
endif()

if( GAUXC_HAS_MPI )
find_dependency( MPI )
endif()
Expand Down
8 changes: 8 additions & 0 deletions cmake/gauxc-exchcxx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ if( NOT ${ExchCXX_FOUND} )
set( EXCHCXX_ENABLE_HIP ${GAUXC_HAS_HIP} CACHE BOOL "" )
set( EXCHCXX_ENABLE_TESTS OFF CACHE BOOL "" )

if( GAUXC_HAS_HIP )
# ROCm's own headers (e.g. amd_hip_vector_types.h) trip -Wshadow.
# Pre-seed this so exchcxx's check_cxx_compiler_flag() probe is
# skipped and it does not add -Wshadow -Werror=shadow, which would
# otherwise turn ROCm's internal warnings into hard build errors.
set( EXCHCXX_CXX_HAS_WSHADOW FALSE CACHE INTERNAL "" )
endif()

FetchContent_Declare(
exchcxx
GIT_REPOSITORY ${GAUXC_EXCHCXX_REPOSITORY}
Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/hipblas_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#ifdef GAUXC_HAS_HIP
#include "hip/hip_runtime.h"
#include <hipblas.h>
#include <hipblas/hipblas.h>

namespace GauXC {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ target_sources(gauxc PRIVATE
kernels/collocation_device.hip
kernels/grid_to_center.hip
kernels/hip_ssf_1d.hip
kernels/hip_ssh_2d.hip
#kernels/hip_ssh_2d.hip # stale/unmaintained 2D SSF weight kernel; see hip_aos_scheme1.cxx
#cuda_aos_scheme1_weights.cu # cuda_ssf_2d w/ CudaAoSScheme1 constants
kernels/pack_submat.hip
kernels/hipblas_extensions.hip
kernels/uvvars.hip
kernels/zmat_vxc.hip
kernels/zmat_fxc.hip
kernels/hip_inc_potential.hip
kernels/symmetrize_mat.hip
kernels/increment_exc_grad.hip
kernels/exx_ek_screening_bfn_stats.hip

)

Expand Down
57 changes: 46 additions & 11 deletions src/xc_integrator/local_work_driver/device/hip/hip_aos_scheme1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "device/hip/hip_backend.hpp"
#include "kernels/grid_to_center.hpp"
#include "kernels/hip_ssf_1d.hpp"
#include "kernels/hip_ssh_2d.hpp"
#include "device/common/device_blas.hpp"

namespace GauXC {

Expand Down Expand Up @@ -42,22 +42,57 @@ void HipAoSScheme1<Base>::partition_weights( XCDeviceData* _data ) {
base_stack.points_y_device, base_stack.points_z_device,
scheme1_stack.dist_scratch_device, ldatoms, *device_backend->master_stream );

#if 1
partition_weights_ssf_2d( data->total_npts_task_batch, data->global_dims.natoms,
// The 2D SSF weight kernel (hip_ssh_2d) is a stale, unmaintained port
// that was never brought up to parity with the 1D path below; CUDA
// disables its own 2D kernel the same way (see
// cuda_aos_scheme1_weights.cu) and uses the 1D path exclusively.
partition_weights_ssf_1d( data->total_npts_task_batch, data->global_dims.natoms,
static_stack.rab_device, ldatoms, static_stack.coords_device,
scheme1_stack.dist_scratch_device, ldatoms, scheme1_stack.iparent_device,
scheme1_stack.dist_nearest_device, base_stack.weights_device,
*device_backend->master_stream );

#else
// Modify weights
partition_weights_ssf_1d( data->total_npts_task_batch, data->global_dims.natoms,
static_stack.rab_device, ldatoms, static_stack.coords_device,
scheme1_stack.dist_scratch_device, ldatoms, scheme1_stack.iparent_device,
scheme1_stack.dist_nearest_device, base_stack.weights_device,
*device_backend->master_stream );
#endif
}


template <typename Base>
void HipAoSScheme1<Base>::eval_weight_1st_deriv_contracted( XCDeviceData* _data, XCWeightAlg alg ) {
if( alg != XCWeightAlg::SSF ) {
GAUXC_GENERIC_EXCEPTION("Weight Algorithm NYI for HIP AoS Scheme1");
}
auto* data = dynamic_cast<Data*>(_data);
if( !data ) GAUXC_BAD_LWD_DATA_CAST();

auto device_backend = dynamic_cast<HIPBackend*>(data->device_backend_);
if( !device_backend ) GAUXC_BAD_BACKEND_CAST();

// make w times f vector
const bool is_UKS = data->allocated_terms.ks_scheme == UKS;
const bool is_GKS = data->allocated_terms.ks_scheme == GKS;
const bool is_pol = is_UKS or is_GKS;
auto base_stack = data->base_stack;
if( is_pol )
increment( data->device_backend_->master_blas_handle(), base_stack.den_z_eval_device,
base_stack.den_s_eval_device, data->total_npts_task_batch );

hadamard_product(data->device_backend_->master_blas_handle(), data->total_npts_task_batch, 1, base_stack.den_s_eval_device, 1,
base_stack.eps_eval_device, 1);

// Compute distances from grid to atomic centers
const auto ldatoms = data->get_ldatoms();
auto static_stack = data->static_stack;
auto scheme1_stack = data->scheme1_stack;
compute_grid_to_center_dist( data->total_npts_task_batch, data->global_dims.natoms,
static_stack.coords_device, base_stack.points_x_device,
base_stack.points_y_device, base_stack.points_z_device,
scheme1_stack.dist_scratch_device, ldatoms, *device_backend->master_stream );

eval_weight_1st_deriv_contracted_ssf_1d( data->total_npts_task_batch, data->global_dims.natoms,
static_stack.rab_device, ldatoms, static_stack.coords_device,
base_stack.points_x_device, base_stack.points_y_device, base_stack.points_z_device,
scheme1_stack.dist_scratch_device, ldatoms, scheme1_stack.iparent_device,
scheme1_stack.dist_nearest_device, base_stack.eps_eval_device, static_stack.exc_grad_device,
*device_backend->master_stream );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct HipAoSScheme1 : public Base {

// API Overrides
void partition_weights( XCDeviceData* ) override final;
void eval_weight_1st_deriv_contracted( XCDeviceData*, XCWeightAlg ) override final;

std::unique_ptr<XCDeviceData> create_device_data(const DeviceRuntimeEnvironment&) override final;

Expand Down
Loading