Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK compliance of adding api version #111

Merged
merged 5 commits into from
Dec 14, 2023
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
cmake_minimum_required(VERSION 3.22)

# Adds version settings and set variable CMAKE_PROJECT_VERSION
project(ReSolve VERSION "0.1.0")
project(ReSolve VERSION "0.99.1")

set(CMAKE_CXX_STANDARD 11)

Expand Down
1 change: 1 addition & 0 deletions resolve/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ target_include_directories(ReSolve INTERFACE

# TODO: Make this PRIVATE dependency (requires refactoring ReSolve code)
target_link_libraries(ReSolve PUBLIC ${ReSolve_Targets_List})
target_link_libraries(ReSolve PRIVATE resolve_version)

# Install targets
install(TARGETS ReSolve
Expand Down
7 changes: 6 additions & 1 deletion resolve/SystemSolver.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cassert>

#include <resolve/matrix/Sparse.hpp>
#include <resolve/vector/Vector.hpp>

Expand Down Expand Up @@ -94,10 +96,13 @@ namespace ReSolve
delete resVector_;
delete factorizationSolver_;
delete refactorizationSolver_;

#if defined(RESOLVE_USE_HIP) || defined(RESOLVE_USE_CUDA)
if (irMethod_ != "none") {
delete iterativeSolver_;
delete gs_;
}
#endif

delete matrixHandler_;
delete vectorHandler_;
Expand Down Expand Up @@ -364,6 +369,7 @@ namespace ReSolve

void SystemSolver::setRefinementMethod(std::string method, std::string gsMethod)
{
#if defined(RESOLVE_USE_HIP) || defined(RESOLVE_USE_CUDA)
if (iterativeSolver_ != nullptr)
delete iterativeSolver_;

Expand All @@ -375,7 +381,6 @@ namespace ReSolve

gsMethod_ = gsMethod;

#if defined(RESOLVE_USE_HIP) || defined(RESOLVE_USE_CUDA)
if (method == "fgmres") {
if (gsMethod == "cgs2") {
gs_ = new GramSchmidt(vectorHandler_, GramSchmidt::cgs2);
Expand Down
7 changes: 4 additions & 3 deletions resolve/resolve_defs.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#cmakedefine RESOLVE_USE_EIGEN
#cmakedefine RESOLVE_USE_KLU
#define RESOLVE_VERSION "@PROJECT_VERSION@"
// #define RESOLVE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
// #define RESOLVE_VERSION_MINOR @PROJECT_VERSION_MINOR@
// #define RESOLVE_VERSION_PATCH @PROJECT_VERSION_PATCH@

#define RESOLVE_VERSION_MAJOR "@PROJECT_VERSION_MAJOR@"
#define RESOLVE_VERSION_MINOR "@PROJECT_VERSION_MINOR@"
#define RESOLVE_VERSION_PATCH "@PROJECT_VERSION_PATCH@"

// /// Date of build with the format "%Y-%m-%d"
// #define RESOLVE_RELEASE_DATE "@RESOLVE_RELEASE_DATE@"
Expand Down
1 change: 1 addition & 0 deletions resolve/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
]]

add_subdirectory(logger)
add_subdirectory(version)
27 changes: 27 additions & 0 deletions resolve/utilities/version/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#[[

@brief Build ReSolve function that returns version at runtime

@author Slaven Peles <[email protected]>

]]

set(Logger_SRC
version.cpp
)

set(Logger_HEADER_INSTALL
version.hpp
)

# Build shared library ReSolve
add_library(resolve_version OBJECT ${Logger_SRC})
set_property(TARGET resolve_version PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(resolve_version PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)

install(FILES ${Logger_HEADER_INSTALL} DESTINATION include/resolve/utilities/version)
25 changes: 25 additions & 0 deletions resolve/utilities/version/version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <unordered_map>
#include <string>

#include "version.hpp"
#include <resolve/resolve_defs.hpp>

namespace ReSolve
{
// Function that splits the verison in major minor and patch ints
int VersionGetVersion(int* major, int* minor, int* patch)
{
*major = atoi(RESOLVE_VERSION_MAJOR);
*minor = atoi(RESOLVE_VERSION_MINOR);
*patch = atoi(RESOLVE_VERSION_PATCH);
return 0;
}

// Function that grabs ReSolves Version as a string
int VersionGetVersionStr(std::string &str)
{
str = RESOLVE_VERSION;
return 0;
}

}
18 changes: 18 additions & 0 deletions resolve/utilities/version/version.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

namespace ReSolve
{

/**
* Sets major, minor, and patch versions for current ReSolve build. The user is
* responsible for free'ing this memory.
*/
int VersionGetVersion(int *, int *, int *);

/**
* Sets string with build version for current ExaGO build in format
* "major.minor.patch". The user is responsible for free'ing this memory.
*/
int VersionGetVersionStr(std::string &);

}
7 changes: 6 additions & 1 deletion tests/functionality/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

]]

# Build basic version test
add_executable(version.exe testVersion.cpp)
target_link_libraries(version.exe PRIVATE ReSolve)

# Build KLU+KLU test
add_executable(klu_klu_test.exe testKLU.cpp)
target_link_libraries(klu_klu_test.exe PRIVATE ReSolve)
Expand Down Expand Up @@ -56,7 +60,7 @@ if(RESOLVE_USE_HIP)
endif(RESOLVE_USE_HIP)

# Install tests
set(installable_tests klu_klu_test.exe)
set(installable_tests klu_klu_test.exe version.exe)

if(RESOLVE_USE_CUDA)
set(installable_tests ${installable_tests}
Expand All @@ -81,6 +85,7 @@ install(DIRECTORY data DESTINATION bin/resolve/tests/functionality)

set(test_data_dir ${CMAKE_SOURCE_DIR}/tests/functionality/)

add_test(NAME version COMMAND $<TARGET_FILE:version.exe> "${test_data_dir}")
add_test(NAME klu_klu_test COMMAND $<TARGET_FILE:klu_klu_test.exe> "${test_data_dir}")
if(RESOLVE_USE_CUDA)
add_test(NAME klu_rf_test COMMAND $<TARGET_FILE:klu_rf_test.exe> "${test_data_dir}")
Expand Down
32 changes: 32 additions & 0 deletions tests/functionality/testVersion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <string>
#include <iostream>


#include <resolve/utilities/version/version.hpp>

//author: RD
//version test to check to make sure ReSolve's version can be printed

/**
* @brief Test ReSolve version
*
* The purpose of this mildly annoying test is to force developers
* to change version at two different places. The hope is this test
* will fail if the version is changed accidentally.
*
* @return int If test was successful return zero
*/
int main()
{
std::string answer("0.99.1");
std::string versionstr;
ReSolve::VersionGetVersionStr(versionstr);
std::cout << "ReSolveVersionGetVersionStr Test: " << versionstr << std::endl << std::endl;

if (versionstr != answer) {
std::cout << "ReSolve version set incorrectly!\n";
return 1;
}

return 0;
}