Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b5d326d
added new permutation kernels
shakedregev Nov 15, 2024
df765dd
edited cmake
shakedregev Nov 21, 2024
1dd20c4
added Hello world tests
shakedregev Nov 21, 2024
66c947f
added Hello world tests
shakedregev Nov 21, 2024
7e53932
resolved conflict
shakedregev Jan 3, 2025
8d9631b
hykkt hello world working, working on linking for permutation
shakedregev Dec 17, 2024
d06e86f
resolved conflict
shakedregev Jan 3, 2025
dc937d5
Ignore files in resolve/hybrid dir.
pelesh Dec 26, 2024
a0e2d5a
Remove cpu subdirectory in hykkt dir.
pelesh Dec 26, 2024
9e91495
hykkt lib builds.
pelesh Dec 26, 2024
93f7198
Fix issues in CMake related to HyKKT build.
pelesh Dec 26, 2024
59c1c6d
resolved conflict
shakedregev Jan 3, 2025
f6aa92c
HyKKT permutation test works.
pelesh Dec 26, 2024
f335cfb
modifications for CUDA
shakedregev Dec 28, 2024
b044767
removed extraneous tests
shakedregev Jan 3, 2025
1fe399f
reformatted according to contributing guidelines
shakedregev Jan 3, 2025
b6b1617
fixed straggling old names
shakedregev Jan 3, 2025
40e671c
stash
shakedregev Jan 6, 2025
f663e36
fixed capitalization for selectionSort2
shakedregev Jan 6, 2025
d439018
fixed capitalization for selectionSort2
shakedregev Jan 6, 2025
e873667
doesn't add hykkt if not using suitesparse
shakedregev Jan 7, 2025
bed24af
doesn't add hykkt if not using suitesparse
shakedregev Jan 7, 2025
0592edc
added namespaces and capitalized enums
shakedregev Jan 7, 2025
91c0f04
fixed naming
shakedregev Jan 8, 2025
4eb17c2
function alignment
shakedregev Jan 8, 2025
fa242c1
namespace fixes, const where possible
shakedregev Jan 8, 2025
7c013d3
Fix issue with linking workspace to HyKKT. (#211)
pelesh Jan 8, 2025
08d08b1
Coding style suggestions (#213)
pelesh Jan 13, 2025
2522866
added requested changes
shakedregev Jan 14, 2025
ea52fbc
addressed Doxygen comment issues
shakedregev Jan 15, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spack-configure-*
docs/dox.warnings
docs/@[email protected]
docs/html

10 changes: 5 additions & 5 deletions cmake/FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ find_library(SUITESPARSE_LIBRARY
${SUITESPARSE_DIR} $ENV{SUITESPARSE_DIR} ${SUITESPARSE_ROOT_DIR}
ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH
PATH_SUFFIXES
lib64 lib)
lib/x86_64-linux-gnu lib64 lib)

if(SUITESPARSE_LIBRARY)
set(SUITESPARSE_LIBRARY CACHE FILEPATH "Path to Suitesparse library")
set(SUITESPARSE_LIBRARY CACHE FILEPATH "File path to Suitesparse library")
get_filename_component(SUITESPARSE_LIBRARY_DIR ${SUITESPARSE_LIBRARY} DIRECTORY CACHE "Suitesparse library directory")
message(STATUS "Found Suitesparse libraries in: " ${SUITESPARSE_LIBRARY_DIR})
mark_as_advanced(SUITESPARSE_LIBRARY SUITESPARSE_LIBRARY_DIR)
Expand All @@ -44,7 +44,7 @@ find_path(SUITESPARSE_INCLUDE_DIR
PATHS
${SUITESPARSE_DIR} $ENV{SUITESPARSE_DIR} ${SUITESPARSE_ROOT_DIR} ${SUITESPARSE_LIBRARY_DIR}/..
PATH_SUFFIXES
include)
include include/suitesparse)

if(SUITESPARSE_LIBRARY)
message(STATUS "Found Suitesparse include: ${SUITESPARSE_INCLUDE_DIR}")
Expand Down Expand Up @@ -75,6 +75,6 @@ else()
message(STATUS "Suitesparse library not found! Please provide correct filepath.")
endif()
if(SUITESPARSE_ROOT_DIR AND NOT SUITESPARSE_INCLUDE_DIR)
message(STATUS "Suitesparse include dir not found! Please provide correct filepath.")
message(STATUS "Suitesparse include dir not found! Please provide correct path.")
endif()
endif()
endif()
8 changes: 8 additions & 0 deletions resolve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ set(ReSolve_LUSOL_SRC
LinSolverDirectLUSOL.cpp
)


# C++ code that links to CUDA SDK libraries
set(ReSolve_CUDASDK_SRC
LinSolverDirectCuSolverGLU.cpp
Expand Down Expand Up @@ -113,6 +114,7 @@ if(RESOLVE_USE_LUSOL)
list(APPEND ReSolve_Targets_List lusol_lib)
endif()


# If no GPU support is enabled, link to dummy device backend
if(NOT RESOLVE_USE_GPU)
add_subdirectory(cpu)
Expand All @@ -137,6 +139,12 @@ if(RESOLVE_USE_HIP)
list(APPEND ReSolve_HEADER_INSTALL ${ReSolve_ROCM_HEADER_INSTALL})
endif()

# Add HyKKT solver
add_subdirectory(hykkt)
#list(APPEND ReSolve_Targets_List resolve_hykkt)



# Set installable targets
install(TARGETS ${ReSolve_Targets_List} EXPORT ReSolveTargets)

Expand Down
55 changes: 55 additions & 0 deletions resolve/hykkt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#[[

@brief Build ReSolve matrix module

@author Slaven Peles <[email protected]>

]]

# C++ code
set(HyKKT_SRC
PermClass.cpp
cpuHykktPermutationKernels.cpp
)

# C++ code that depends on CUDA SDK libraries
set(HyKKT_CUDASDK_SRC
)

# and on HIP
set(HyKKT_ROCM_SRC
)

# Header files to be installed
set(HyKKT_HEADER_INSTALL
PermClass.hpp
cpuHykktPermutationKernels.hpp
)

# Build shared library ReSolve::matrix
add_library(resolve_hykkt SHARED ${HyKKT_SRC})
target_link_libraries(resolve_hykkt PUBLIC resolve_logger resolve_vector ${suitesparse_amd})
target_include_directories(resolve_hykkt PUBLIC ${SUITESPARSE_INCLUDE_DIR})

# Link to CUDA ReSolve backend if CUDA is support enabled
if (RESOLVE_USE_CUDA)
# target_sources(resolve_hykkt PRIVATE ${HyKKT_CUDASDK_SRC})
# target_link_libraries(resolve_hykkt PUBLIC resolve_backend_cuda)
endif()

if (RESOLVE_USE_HIP)
# target_sources(resolve_hykkt PRIVATE ${HyKKT_ROCM_SRC})
# target_link_libraries(resolve_hykkt PUBLIC resolve_backend_hip)
endif()

# Link to dummy device backend if GPU support is not enabled
if (NOT RESOLVE_USE_GPU)
target_link_libraries(resolve_hykkt PUBLIC resolve_backend_cpu)
endif()

target_include_directories(resolve_hykkt INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

install(FILES ${HyKKT_HEADER_INSTALL} DESTINATION include/resolve/hykkt)
122 changes: 122 additions & 0 deletions resolve/hykkt/PermClass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include <resolve/hykkt/PermClass.hpp>
#include <resolve/hykkt/cpuHykktPermutationKernels.hpp>
#include <cstdio>
#include "amd.h"

// Creates a class for the permutation of $H_\gamma$ in (6)
PermClass::PermClass(int n_h, int nnz_h, int nnz_j)
: n_h_(n_h),
nnz_h_(nnz_h),
nnz_j_(nnz_j)
{
allocateWorkspace();
}

PermClass::~PermClass()
{
if(perm_is_default_){
delete [] perm_;
}
delete [] rev_perm_;
delete [] perm_map_h_;
delete [] perm_map_j_;
delete [] perm_map_jt_;
}

void PermClass::addHInfo(int* h_i, int* h_j)
{
h_i_ = h_i;
h_j_ = h_j;
}

void PermClass::addJInfo(int* j_i, int* j_j, int n_j, int m_j)
{
j_i_ = j_i;
j_j_ = j_j;
n_j_ = n_j;
m_j_ = m_j;
}

void PermClass::addJtInfo(int* jt_i, int* jt_j)
{
jt_i_ = jt_i;
jt_j_ = jt_j;
}

void PermClass::addPerm(int* custom_perm)
{
perm_is_default_ = false;
perm_ = custom_perm;
}

// symAmd permutation of $H_\gamma$ in (6)
void PermClass::symAmd()
{
double Control[AMD_CONTROL], Info[AMD_INFO];

amd_defaults(Control);
amd_control(Control);

int result = amd_order(n_h_, h_i_, h_j_, perm_, Control, Info);

if (result != AMD_OK)
{
printf("AMD failed\n");
exit(1);
}
}

void PermClass::invertPerm()
{
reversePerm(n_h_, perm_, rev_perm_);
}

void PermClass::vecMapRC(int* b_i, int* b_j)
{
makeVecMapRC(n_h_, h_i_, h_j_, perm_, rev_perm_, b_i, b_j, perm_map_h_);
}

void PermClass::vecMapC(int* b_j)
{
makeVecMapC(n_j_, j_i_, j_j_, rev_perm_, b_j, perm_map_j_);
}

void PermClass::vecMapR(int* b_i, int* b_j)
{
makeVecMapR(m_j_, jt_i_, jt_j_, perm_, b_i, b_j, perm_map_jt_);
}

void PermClass::map_index(PermutationType permutation,
double* old_val,
double* new_val)
{
switch(permutation)
{
case perm_v:
cpuMapIdx(n_h_, perm_, old_val, new_val);
break;
case rev_perm_v:
cpuMapIdx(n_h_, rev_perm_, old_val, new_val);
break;
case perm_h_v:
cpuMapIdx(nnz_h_, perm_map_h_, old_val, new_val);
break;
case perm_j_v:
cpuMapIdx(nnz_j_, perm_map_j_, old_val, new_val);
break;
case perm_jt_v:
cpuMapIdx(nnz_j_, perm_map_jt_, old_val, new_val);
break;
default:
printf("Valid arguments are perm_v, rev_perm_v, perm_h_v, perm_j_v, perm_jt_v\n");
}
}

void PermClass::allocateWorkspace()
{
perm_ = new int[n_h_];
rev_perm_ = new int[n_h_];
perm_map_h_ = new int[nnz_h_];
perm_map_j_ = new int[nnz_j_];
perm_map_jt_ = new int[nnz_j_];
}
Loading
Loading