mirror of
https://github.com/fumiama/base16384-sycl.git
synced 2026-06-17 09:00:49 +08:00
optimize: project structure
This commit is contained in:
17
libs/CMakeLists.txt
Normal file
17
libs/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
file(GLOB CPP_FILES "*.cpp")
|
||||
|
||||
set(LOCAL_B14LIBS "")
|
||||
|
||||
foreach(CPP_FILE ${CPP_FILES})
|
||||
# name without .cpp
|
||||
get_filename_component(TARGET_NAME ${CPP_FILE} NAME_WE)
|
||||
message(STATUS "Add lib: ${TARGET_NAME}")
|
||||
add_library(${TARGET_NAME} STATIC ${CPP_FILE})
|
||||
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
|
||||
|
||||
list(APPEND LOCAL_B14LIBS ${TARGET_NAME})
|
||||
endforeach()
|
||||
|
||||
set(B14LIBS ${LOCAL_B14LIBS} PARENT_SCOPE)
|
||||
29
libs/errors.cpp
Normal file
29
libs/errors.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "errors.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <sycl/sycl.hpp>
|
||||
|
||||
template <typename T>
|
||||
concept has_what_concept_t = requires(T t) { t.what(); };
|
||||
|
||||
template <has_what_concept_t T>
|
||||
void print_what(T e, std::string msg) {
|
||||
std::cerr << msg << e.what() << std::endl;
|
||||
}
|
||||
|
||||
errors_code_enum_t failed(std::function<void(void)> fn) {
|
||||
try {
|
||||
fn();
|
||||
} catch (sycl::exception &e) {
|
||||
print_what(e, "Caught sync SYCL exception: ");
|
||||
return errors_code_sync_sycl_exception;
|
||||
} catch (std::exception &e) {
|
||||
print_what(e, "Caught std exception: ");
|
||||
return errors_code_std_exception;
|
||||
} catch (...) {
|
||||
std::cerr << "Caught unknown exception." << std::endl;
|
||||
return errors_code_unknown_exception;
|
||||
}
|
||||
return errors_code_ok;
|
||||
}
|
||||
Reference in New Issue
Block a user