Skip to content

Commit

Permalink
Hack to make HIP build work; warnings fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelesh committed Oct 26, 2023
1 parent 3bcdccc commit 0983004
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 28 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ if(RESOLVE_USE_HIP)
check_language(HIP)
include(ReSolveFindHipLibraries)

# set(CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS} -D__HIP_PLATFORM_AMD__")
include_directories("/opt/rocm-5.6.0/include")
# This is just an agly hack to make HIP build work
get_target_property(hip_includes hip::device INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "HIP include directories: ${hip_includes}")
include_directories(${hip_includes})
else()
message(STATUS "Not using HIP")
endif(RESOLVE_USE_HIP)
Expand Down
10 changes: 8 additions & 2 deletions cmake/ReSolveFindHipLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ find_package(hip REQUIRED)
find_package(hipblas REQUIRED)

target_link_libraries(resolve_hip INTERFACE
hip::host
#hip::host
hip::device
roc::hipblas
#roc::hipblas
)

# get_target_property(hip_includes hip::device INTERFACE_INCLUDE_DIRECTORIES)
# message(STATUS "HIP include directories: ${hip_includes}")

# get_target_property(resolve_hip_includes resolve_hip INTERFACE_INCLUDE_DIRECTORIES)
# message(STATUS "ReSolve HIP include directories: ${resolve_hip_includes}")

install(TARGETS resolve_hip EXPORT ReSolveTargets)
7 changes: 4 additions & 3 deletions examples/r_KLU_GLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ int main(int argc, char *argv[])
workspace_CUDA->initializeHandles();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace_CUDA);
ReSolve::VectorHandler* vector_handler = new ReSolve::VectorHandler(workspace_CUDA);
real_type* rhs;
real_type* x;
real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs;
vector_type* vec_x;
Expand Down Expand Up @@ -159,7 +159,8 @@ int main(int argc, char *argv[])
delete A;
delete KLU;
delete GLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down
7 changes: 4 additions & 3 deletions examples/r_KLU_GLU_matrix_values_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ int main(int argc, char *argv[])
workspace_CUDA->initializeHandles();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace_CUDA);
ReSolve::VectorHandler* vector_handler = new ReSolve::VectorHandler(workspace_CUDA);
real_type* rhs;
real_type* x;
real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs;
vector_type* vec_x;
Expand Down Expand Up @@ -170,7 +170,8 @@ int main(int argc, char *argv[])
delete A;
delete KLU;
delete GLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down
7 changes: 4 additions & 3 deletions examples/r_KLU_KLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ int main(int argc, char *argv[])
ReSolve::LinAlgWorkspaceCpu* workspace = new ReSolve::LinAlgWorkspaceCpu();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace);
ReSolve::VectorHandler* vector_handler = new ReSolve::VectorHandler(workspace);
real_type* rhs;
real_type* x;
real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs;
vector_type* vec_x;
Expand Down Expand Up @@ -148,7 +148,8 @@ int main(int argc, char *argv[])
//now DELETE
delete A;
delete KLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete matrix_handler;
Expand Down
7 changes: 4 additions & 3 deletions examples/r_KLU_KLU_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ int main(int argc, char *argv[])
ReSolve::LinAlgWorkspaceCpu* workspace = new ReSolve::LinAlgWorkspaceCpu();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace);
ReSolve::VectorHandler* vector_handler = new ReSolve::VectorHandler(workspace);
real_type* rhs;
real_type* x;
real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs;
vector_type* vec_x;
Expand Down Expand Up @@ -111,7 +111,8 @@ int main(int argc, char *argv[])
//now DELETE
delete A;
delete KLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete matrix_handler;
Expand Down
7 changes: 4 additions & 3 deletions examples/r_KLU_rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ int main(int argc, char *argv[] )
workspace_CUDA->initializeHandles();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace_CUDA);
ReSolve::VectorHandler* vector_handler = new ReSolve::VectorHandler(workspace_CUDA);
real_type* rhs;
real_type* x;
real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs;
vector_type* vec_x;
Expand Down Expand Up @@ -173,7 +173,8 @@ int main(int argc, char *argv[] )
delete A;
delete KLU;
delete Rf;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down
3 changes: 3 additions & 0 deletions examples/r_KLU_rf_FGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,8 @@ int main(int argc, char *argv[])

} // for (int i = 0; i < numSystems; ++i)

delete [] x;
delete [] rhs;

return 0;
}
3 changes: 3 additions & 0 deletions examples/r_KLU_rf_FGMRES_reuse_factorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,8 @@ int main(int argc, char *argv[])

}

delete [] x;
delete [] rhs;

return 0;
}
2 changes: 1 addition & 1 deletion resolve/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set_source_files_properties(${ReSolve_HIP_SRC} PROPERTIES LANGUAGE HIP)
add_library(resolve_backend_hip SHARED ${ReSolve_HIP_SRC})
target_link_libraries(resolve_backend_hip PRIVATE resolve_logger)
target_link_libraries(resolve_backend_hip PRIVATE resolve_hip)
# target_include_directories(resolve_backend_hip PUBLIC "/opt/rocm-5.6.0/include")
#target_include_directories(resolve_backend_hip PUBLIC ${hip_includes})
target_include_directories(resolve_backend_hip INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
Expand Down
5 changes: 3 additions & 2 deletions tests/functionality/testKLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char *argv[])
return -1;
}
real_type* rhs = ReSolve::io::readRhsFromFile(rhs1_file);
real_type* x = new real_type[A->getNumRows()];
real_type* x = new real_type[A->getNumRows()];
vector_type* vec_rhs = new vector_type(A->getNumRows());
vector_type* vec_x = new vector_type(A->getNumRows());
vector_type* vec_r = new vector_type(A->getNumRows());
Expand Down Expand Up @@ -215,7 +215,8 @@ int main(int argc, char *argv[])
//now DELETE
delete A;
delete KLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete matrix_handler;
Expand Down
5 changes: 3 additions & 2 deletions tests/functionality/testKLU_GLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
return -1;
}
real_type* rhs = ReSolve::io::readRhsFromFile(rhs1_file);
real_type* x = new real_type[A->getNumRows()];
real_type* x = new real_type[A->getNumRows()];
vector_type* vec_rhs = new vector_type(A->getNumRows());
vector_type* vec_x = new vector_type(A->getNumRows());
vec_x->allocate("cpu");//for KLU
Expand Down Expand Up @@ -239,7 +239,8 @@ int main(int argc, char *argv[])
delete A;
delete KLU;
delete GLU;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down
5 changes: 3 additions & 2 deletions tests/functionality/testKLU_Rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
return -1;
}
real_type* rhs = ReSolve::io::readRhsFromFile(rhs1_file);
real_type* x = new real_type[A->getNumRows()];
real_type* x = new real_type[A->getNumRows()];
vector_type* vec_rhs = new vector_type(A->getNumRows());
vector_type* vec_x = new vector_type(A->getNumRows());
vector_type* vec_r = new vector_type(A->getNumRows());
Expand Down Expand Up @@ -243,7 +243,8 @@ int main(int argc, char *argv[])
delete A;
delete KLU;
delete Rf;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down
5 changes: 3 additions & 2 deletions tests/functionality/testKLU_Rf_FGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char *argv[])
return -1;
}
real_type* rhs = ReSolve::io::readRhsFromFile(rhs1_file);
real_type* x = new real_type[A->getNumRows()];
real_type* x = new real_type[A->getNumRows()];
vector_type* vec_rhs = new vector_type(A->getNumRows());
vector_type* vec_x = new vector_type(A->getNumRows());
vector_type* vec_r = new vector_type(A->getNumRows());
Expand Down Expand Up @@ -264,7 +264,8 @@ int main(int argc, char *argv[])
delete GS;
delete FGMRES;
delete Rf;
delete x;
delete [] x;
delete [] rhs;
delete vec_r;
delete vec_x;
delete workspace_CUDA;
Expand Down

0 comments on commit 0983004

Please sign in to comment.