Skip to content
Closed
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
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})


option(COMPILE_DOCS "This is settable from the command line" OFF)
option(ENABLE_DATABASE "Set this for the database connector to work" OFF)
option(ENABLE_PYTHON "Set this for python connector to work" OFF)
option(ENABLE_CUDA "Enable CUDA execution for some faster data structures" OFF)

if (ENABLE_DATABASE)
add_definitions(-D__FLEXFRINGE_DATABASE)
Expand All @@ -29,6 +31,17 @@ if (ENABLE_PYTHON)
add_definitions(-D__FLEXFRINGE_PYTHON)
endif()

if (ENABLE_CUDA)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
add_definitions(-D__FLEXFRINGE_CUDA)
enable_language(CUDA)
else()
message(WARNING "Could not find CUDA on system. Proceeding without.")
endif()
endif()

#set(CMAKE_MESSAGE_LOG_LEVEL WARNING)

# Default compiler flags:
Expand Down Expand Up @@ -191,6 +204,11 @@ if (ENABLE_DATABASE)
target_link_libraries(flexfringe libpqxx::pqxx)
endif()

if(CMAKE_CUDA_COMPILER)
find_library(CUDART_LIBRARY cudart ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(ActiveLearning ${CUDART_LIBRARY})
endif()


find_package(Threads)
target_link_libraries(flexfringe ${CMAKE_THREAD_LIBS_INIT}) # For pthreads
Expand Down
8 changes: 7 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ file(WRITE "gitversion.cpp" "const char *gitversion = \"${Gitversion}\";")
## create the evaluators.h file
file(GLOB Files "${CMAKE_CURRENT_SOURCE_DIR}/evaluation/*.h")
file(WRITE "evaluators.h" "#ifndef __ALL_HEADERS__ \n#define __ALL_HEADERS__ \n\n")

foreach (Filepath ${Files})
get_filename_component(Filename ${Filepath} NAME)
file(APPEND "evaluators.h" "#include \"${Filename}\"\n")
Expand Down Expand Up @@ -140,7 +141,12 @@ file(APPEND "${cmakelists_eval}" " \"../active_learning/memory/incomplete_infor
file(APPEND "${cmakelists_eval}" " \"../active_learning/system_under_learning\"\n")
file(APPEND "${cmakelists_eval}" " \"../active_learning/system_under_learning/neural_network_suls\"\n")
file(APPEND "${cmakelists_eval}" " \"../active_learning/system_under_learning/benchmark_parsers\"\n")
file(APPEND "${cmakelists_eval}" ")\n\n\n")
file(APPEND "${cmakelists_eval}" ")\n\n")

# the cuda directives
file(APPEND "${cmakelists_eval}" "if(CMAKE_CUDA_COMPILER)\n")
file(APPEND "${cmakelists_eval}" " include_directories(\$\{CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES\})\n")
file(APPEND "${cmakelists_eval}" "endif()\n\n")

# "${CMAKE_CURRENT_SOURCE_DIR}/../active_learning//oracle/cex_search_strategies"
# "${CMAKE_CURRENT_SOURCE_DIR}/../active_learning//oracle/cex_conflict_search"
Expand Down
28 changes: 26 additions & 2 deletions source/active_learning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/system_under_learning/benchmark_parsers"
)

if(CMAKE_CUDA_COMPILER)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
"${CMAKE_CURRENT_SOURCE_DIR}/active_learning_util/cuda"
"${CMAKE_CURRENT_SOURCE_DIR}/memory/distinguishing_sequences/cuda"
)
endif()

add_library(ActiveLearning STATIC
set(ACTIVE_LEARNING_FILES
active_learning_mode.h
active_learning_mode.cpp

Expand Down Expand Up @@ -188,9 +194,27 @@ add_library(ActiveLearning STATIC
)


if(CMAKE_CUDA_COMPILER)
set(CUDA_FILES
active_learning_util/cuda/cuda_common.cuh
active_learning_util/cuda/cuda_common.cu
memory/distinguishing_sequences/cuda/distinguishing_sequences_gpu.cuh
memory/distinguishing_sequences/cuda/distinguishing_sequences_gpu.cu
)

set(ACTIVE_LEARNING_FILES
${ACTIVE_LEARNING_FILES}
${CUDA_FILES}
)

set_source_files_properties(${CUDA_FILES} PROPERTIES LANGUAGE CUDA)
endif()

add_library(ActiveLearning STATIC ${ACTIVE_LEARNING_FILES})

if (ENABLE_PYTHON)
target_link_libraries(ActiveLearning ${PYTHON_LIBRARIES})
endif()
if (ENABLE_DATABASE)
target_link_libraries(ActiveLearning libpqxx::pqxx)
endif()
endif()
3 changes: 3 additions & 0 deletions source/active_learning/active_learning_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ int active_learning_mode::run() {
unique_ptr<algorithm_base> algorithm = algorithm_factory::create_algorithm_obj();
algorithm->run(id);

#ifdef __CUDA
cudaDeviceReset();
#endif
// Hielke: Can we we this one better? For example, we do it in the constructor of the corresponding algorithms
/* LOG_S(INFO) << "Learning (partly) passively. Therefore read in input-data.";
get_inputdata();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,7 @@ trace* active_learning_namespace::vector_to_trace(const vector<int>& vec, inputd
throw runtime_error("We should not reach here. What happened?");
}*/

/**
* @brief For debugging.
*/
void active_learning_namespace::print_list(const list<int>& l) {
for (const auto s : l) cout << s << " ";
cout << endl;
}

void active_learning_namespace::print_vector(const vector<int>& l) {
void active_learning_namespace::print_span(std::span<const int> l) {
for (const auto s : l) cout << s << " ";
cout << endl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <functional>
#include <list>
#include <span>
#include <unordered_map>
#include <utility>

Expand Down Expand Up @@ -98,9 +99,7 @@ namespace active_learning_namespace {
std::cout << std::endl;
}

[[maybe_unused]] void print_list(const std::list<int>& l);

void print_vector(const std::vector<int>& l);
void print_span(std::span<const int> l);
} // namespace active_learning_namespace


Expand Down
29 changes: 29 additions & 0 deletions source/active_learning/active_learning_util/cuda/cuda_common.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @file cuda_common.cu
* @author Robert Baumgartner (r.baumgartner-1@tudelft.nl)
* @brief
* @version 0.1
* @date 2025-07-13
*
* @copyright Copyright (c) 2025
*
*/

#ifndef __FLEXFRINGE_CUDA
#include<type_traits>
static_assert(std::integral_constant<bool, false>::value, "cuda_common.cu included even though CUDA not enabled in project.");
#endif

#include "cuda_common.cuh"

#include <iostream>

void cuda_common::gpuAssert(cudaError_t code, const char *file, int line, bool abort)
{
if (code != cudaSuccess)
{
//fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
std::cerr << "GPUassert: " << cudaGetErrorString(code) << " " << file << " " << line;
if (abort) exit(code);
}
}
26 changes: 26 additions & 0 deletions source/active_learning/active_learning_util/cuda/cuda_common.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file cuda_common.cuh
* @author Robert Baumgartner (r.baumgartner-1@tudelft.nl)
* @brief
* @version 0.1
* @date 2025-07-12
*
* @copyright Copyright (c) 2025
*
*/

#ifndef __FLEXFRINGE_CUDA
#include<type_traits>
static_assert(std::integral_constant<bool, false>::value, "cuda_common.cuh included even though CUDA not enabled in project.");
#endif

#ifndef __CUDA_COMMON_CUH__
#define __CUDA_COMMON_CUH__

#include "cuda.h"

namespace cuda_common {
void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true);
}

#endif // __CUDA_COMMON_CUH__
12 changes: 8 additions & 4 deletions source/active_learning/algorithms/paul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ void paul_algorithm::update_node_data(apta_node* n, std::unique_ptr<apta>& aut)
ds_handler->complete_node(n, aut);
}

if(n_data->get_predictions().size() != ds_handler->size()){
//if(n->get_depth() >= 10)
// return;

if(n_data->get_n_predictions() != ds_handler->size()){
auto y_pred = ds_handler->predict_node_with_sul_layer_wise(*aut, n);
n_data->set_predictions(std::move(y_pred));
}
Expand Down Expand Up @@ -159,7 +162,8 @@ refinement* paul_algorithm::check_blue_node_for_merge_partner(apta_node* const b
// continue;
//}
}


//if(ds_handler->get_score() > 0)
ref->score = ds_handler->get_score(); // score computed in check_consistency() or distributions_consistent()
if(ref->score > 0){
rs.insert(ref);
Expand Down Expand Up @@ -375,14 +379,14 @@ list<refinement*> paul_algorithm::find_hypothesis(list<refinement*>& previous_re
} */

//#ifndef NDEBUG
{
/* {
static int c = 0;
merger->print_dot("after_" + to_string(c++) + ".dot");

if(c%10==0){
output_manager::print_current_automaton(merger.get(), "model.", to_string(c) + ".intermediate");
}
}
} */

//#endif

Expand Down
Loading
Loading