Skip to content

Commit

Permalink
Final touches to version test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelesh committed Dec 14, 2023
1 parent 968411c commit 3cb5172
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 60 deletions.
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 @@ -74,6 +74,7 @@ set(ReSolve_Targets_List
resolve_logger
resolve_tpl
resolve_workspace
resolve_version
)

# Temporary until there is CPU-only option for FGMRES
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
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)
20 changes: 0 additions & 20 deletions resolve/utilities/version.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions resolve/utilities/version.hpp

This file was deleted.

26 changes: 26 additions & 0 deletions resolve/utilities/version/CmakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[[

@brief Build ReSolve output log system

@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})

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 &);

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

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

# Build KLU+KLU test
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;
}
19 changes: 0 additions & 19 deletions tests/functionality/testversion.cpp

This file was deleted.

0 comments on commit 3cb5172

Please sign in to comment.