Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ffe1e1c
merge branch 'develop' for new version 0.0.0
Apr 14, 2020
c96f92f
merge branch 'develop' for new version 0.1.0
Jun 18, 2020
ea13057
merge branch 'develop' for new version 0.1.1
Jun 19, 2020
f3572b4
merge branch 'develop' for new version 1.0.0
Nov 1, 2020
33208c7
merge branch 'develop' for new version 1.0.1
Nov 1, 2020
5408880
merge branch 'develop' for new version 1.0.2
Nov 22, 2020
3041617
(cpp17) fixed compile issue when using C++17 standard.
florian-arrestier-idnow Apr 28, 2021
5d76c4e
(cpp17) removing variant.h library as there is std::variant in cpp17
florian-arrestier-idnow May 28, 2021
cf2f70a
(sonar) fixed vulnaribility warning with sprintf.
florian-arrestier-idnow May 28, 2021
c785898
(sonar) fixed overflow bug in Vertex::setName
florian-arrestier-idnow May 28, 2021
33f3814
(sonar) fixed potential division by zeron in RoundRobinMapper
florian-arrestier-idnow May 28, 2021
617a84d
(misc) set functions as static instead of const in CompilerExpression.
florian-arrestier-idnow May 28, 2021
532d446
(misc) renamed array_handle -> array_view. using std::unique_ptr for …
florian-arrestier-idnow May 28, 2021
660046f
(sonar) misc cleans.
florian-arrestier-idnow May 28, 2021
66035fc
Merge branch 'fixsonar' of github.com:preesm/spider2 into cpp17
florian-arrestier-idnow May 28, 2021
05e4029
(fix) fixed doxygen url version.
florian-arrestier-idnow May 28, 2021
9d91b78
Merge branch 'fixsonar' of github.com:preesm/spider2 into cpp17
florian-arrestier-idnow May 28, 2021
cdcd7e1
[cpp] fixed signed / unsigned warnings
farresti Feb 16, 2025
9faf2cf
[cpp] fixed namespace with stackArray. fixed allocator-test.
farresti Feb 16, 2025
5f71c01
[cpp17] fixed Vertex::setName
farresti Feb 16, 2025
6f63ea4
[cpp17] fixed seg fault in execDependenciesImpl.h. Fixed warnings in …
farresti Feb 16, 2025
813af34
[misc] fixing potential nullptr deferencing
farresti Feb 16, 2025
02c4e5d
[misc] fixed GCC warning and usage of multithread during link time optim
farresti Feb 16, 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- choco install visualstudio2019-workload-vctools
install:
- mkdir doxygen && cd doxygen
- curl https://www.doxygen.nl/files/doxygen-1.8.20.windows.x64.bin.zip -o doxygen.zip
- curl https://www.doxygen.nl/files/doxygen-1.9.1.windows.x64.bin.zip -o doxygen.zip
- unzip doxygen.zip
- export PATH=$PATH:$PWD
- cd ..
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (MSVC)
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> CONFIGURATIONS "Debug" "RelWithDebInfo" DESTINATION "${CMAKE_INSTALL_BINDIR}")
else ()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg -O0 --coverage -ftest-coverage -fprofile-arcs")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -fno-rtti -flto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -fno-rtti -flto=auto")
message(STATUS "Using Link Time Optimization (-flto) on GNU platforms.")
if (${CMAKE_GENERATOR} MATCHES "MinGW Makefiles")
# To prevent a redefinition conflict
Expand Down Expand Up @@ -140,8 +140,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

# Setting C++ standard to C++11
set(CMAKE_CXX_STANDARD 11)
# Setting C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# We use
Expand Down
4 changes: 4 additions & 0 deletions libspider/api/debug-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void spider::api::enableLogger(log::Type type) {
case log::Type::EXPR:
log::enable<log::EXPR>();
break;
default:
printer::fprintf(stderr, "Unsupported logger enum type.\n");
}
}

Expand Down Expand Up @@ -116,6 +118,8 @@ void spider::api::disableLogger(log::Type type) {
case log::Type::EXPR:
log::disable<log::EXPR>();
break;
default:
printer::fprintf(stderr, "Unsupported logger enum type.\n");
}
}

Expand Down
6 changes: 2 additions & 4 deletions libspider/api/global-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <cstddef>
#include <array>
#include <functional>
#include <memory>

/* === non-namespace Enumeration(s) === */

Expand Down Expand Up @@ -288,10 +289,7 @@ namespace spider {
return nameArray;
}

inline std::array<Stack *, STACK_COUNT> &stackArray() {
static std::array<Stack *, STACK_COUNT> stackArray = {{ nullptr }};
return stackArray;
}
std::array<std::unique_ptr<Stack>, STACK_COUNT> &stackArray();

/* === Type definition(s) === */

Expand Down
12 changes: 9 additions & 3 deletions libspider/api/spider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ static void printConfig(const spider::StartUpConfig &cfg) {

/* === Function(s) definition === */

std::array<std::unique_ptr<spider::Stack>, STACK_COUNT> &spider::stackArray() {
static std::array<std::unique_ptr<spider::Stack>, STACK_COUNT> stackArray = {{ nullptr }};
return stackArray;
}

spider::StartUpConfig spider::parseInputArguments(int32_t argc, char **argv) {
spider::log::info("parsing of input arguments is not yet supported.\n");
for (auto i = 0; i < argc; ++i) {
Expand All @@ -129,7 +134,7 @@ void spider::api::setStackAllocatorPolicy(StackID stackId,
size_t alignment,
size_t size,
void *externBuffer) {
auto *stack = stackArray()[static_cast<size_t>(stackId)];
auto &stack = stackArray()[static_cast<size_t>(stackId)];
switch (policy) {
case AllocatorPolicy::FREELIST_FIND_FIRST:
stack->setPolicy(new FreeListAllocatorPolicy(size, externBuffer, FreeListPolicy::FIND_FIRST, alignment));
Expand All @@ -143,6 +148,8 @@ void spider::api::setStackAllocatorPolicy(StackID stackId,
case AllocatorPolicy::LINEAR_STATIC:
stack->setPolicy(new LinearStaticAllocator(size, externBuffer, alignment));
break;
default:
throwSpiderException("unsupported AllocatorPolicy value.");
}
}

Expand All @@ -161,7 +168,7 @@ void spider::start(const StartUpConfig &cfg) {
/* == Initialize stacks == */
auto it = EnumIterator<StackID>{ }.begin();
for (auto &stack : stackArray()) {
stack = new Stack(*(it++));
stack = std::unique_ptr<Stack>(new Stack(*(it++)));
}
if (cfg.generalStackAllocatorPolicy_ != AllocatorPolicy::GENERIC) {
api::setStackAllocatorPolicy(StackID::GENERAL,
Expand Down Expand Up @@ -296,7 +303,6 @@ void spider::quit() {
totalAverage += stack->average();
totalPeak += stack->peak();
}
delete stack;
}
Stack::print("Total", totalPeak, totalAverage, 1, totalUsage);

Expand Down
8 changes: 4 additions & 4 deletions libspider/archi/Cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <archi/Cluster.h>
#include <archi/Platform.h>
#include <archi/MemoryInterface.h>
#include <containers/array_handle.h>
#include <containers/array_view.h>

/* === Static variable(s) === */

Expand All @@ -48,14 +48,14 @@
spider::Cluster::Cluster(size_t PECount, MemoryInterface *memoryInterface) :
memoryInterface_{ memoryInterface } {
PEArray_ = allocate<PE *, StackID::ARCHI>(PECount);
make_handle(PEArray_, PECount).assign(nullptr);
make_view(PEArray_, PECount).assign(nullptr);
if (!memoryInterface) {
throwSpiderException("nullptr MemoryInterface");
}
}

spider::Cluster::~Cluster() {
for (auto &pe : make_handle(PEArray_, PECount_)) {
for (auto &pe : make_view(PEArray_, PECount_)) {
destroy(pe);
}
destroy(PEArray_);
Expand All @@ -66,7 +66,7 @@ void spider::Cluster::addPE(PE *pe) {
if (!pe) {
return;
}
make_handle(PEArray_, PECount_ + 1).at(PECount_) = pe;
make_view(PEArray_, PECount_ + 1).at(PECount_) = pe;
PECount_++; /* = In case at throws, PECount is not change = */
LRTCount_ += pe->isLRT();
if (platform()) {
Expand Down
12 changes: 6 additions & 6 deletions libspider/archi/Cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <archi/PE.h>
#include <common/Types.h>
#include <containers/array.h>
#include <containers/array_handle.h>
#include <containers/array_view.h>

namespace spider {

Expand Down Expand Up @@ -79,7 +79,7 @@ namespace spider {
* @throws std::out_of_range if PE ix is out of bound.
*/
inline void setPEStatus(size_t ix, bool status) {
auto handle = make_handle(PEArray_, PECount_);
auto handle = make_view(PEArray_, PECount_);
status ? handle.at(ix)->enable() : handle.at(ix)->disable();
}

Expand All @@ -89,8 +89,8 @@ namespace spider {
* @brief Get the array of processing element of the cluster.
* @return const reference to the @refitem spider::array of @refitem PE of the cluster.
*/
inline array_handle<PE *> peArray() const {
return make_handle(PEArray_, PECount_);
inline array_view<PE *> peArray() const {
return make_view(PEArray_, PECount_);
}

/**
Expand All @@ -108,7 +108,7 @@ namespace spider {
* @throws @refitem std::out_of_range if ix is out of bound
*/
inline PE *at(size_t ix) const {
return make_handle(PEArray_, PECount_).at(ix);
return make_view(PEArray_, PECount_).at(ix);
}

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace spider {
* @brief Get the platform of the cluster.
* @return @refitem Platform of the cluster.
*/
inline Platform *platform() const {
static inline Platform *platform() {
return archi::platform();
}

Expand Down
4 changes: 2 additions & 2 deletions libspider/archi/MemoryBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
spider::MemoryBus::MemoryBus() {
sendCostRoutine_ = [](u64) -> u64 { return 0; };
receiveCostRoutine_ = [](u64) -> u64 { return 0; };
sendRoutine_ = [](i64, const void *, const void *) { };
receiveRoutine_ = [](i64, const void *, const void *) { };
sendRoutine_ = [](i64, const void *, const void *) { /* = empty method = */ };
receiveRoutine_ = [](i64, const void *, const void *) { /* = empty method = */ };
}

uint64_t spider::MemoryBus::sendCost(uint64_t size) const {
Expand Down
10 changes: 5 additions & 5 deletions libspider/common/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/* === Defines === */

/* == Size of 50 minimum is required for the error message associated == */
#define EXCEPTION_BUFFER_SIZE 400
constexpr auto EXCEPTION_BUFFER_SIZE = 400;

/* === Macros === */

Expand Down Expand Up @@ -79,12 +79,12 @@ namespace spider {
const char *msg, Args &&...args)
: exceptionMessage_{ } {
/* == Writes exception header == */
int n = printer::sprintf(exceptionMessage_, EXCEPTION_BUFFER_SIZE, "%s::%s(%d): ", fileName,
fctName, lineNumber);
int n = printer::snprintf(exceptionMessage_, EXCEPTION_BUFFER_SIZE, "%s::%s(%d): ", fileName,
fctName, lineNumber);

/* == Write the actual exception message == */
n = printer::sprintf(exceptionMessage_ + n, static_cast<size_t>(EXCEPTION_BUFFER_SIZE - n), msg,
std::forward<Args>(args)...);
n = printer::snprintf(exceptionMessage_ + n, static_cast<size_t>(EXCEPTION_BUFFER_SIZE - n), msg,
std::forward<Args>(args)...);
if (n > EXCEPTION_BUFFER_SIZE) {
printer::fprintf(stderr, "Exception: ERROR: exception message too big.\n");
printer::fprintf(stderr, "Partially recovered exception: %s\n", exceptionMessage_);
Expand Down
16 changes: 8 additions & 8 deletions libspider/common/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
namespace spider {
namespace log {

constexpr static const char green[] = "\x1B[32m";
constexpr static const char red[] = "\x1B[31m";
constexpr static const char yellow[] = "\x1B[33m";
constexpr static const char blue[] = "\x1B[34m";
constexpr static const char magenta[] = "\x1B[35m";
constexpr static const char cyan[] = "\x1B[36m";
constexpr static const char white[] = "\x1B[37m";
constexpr static const char normal[] = "\x1B[0m";
constexpr static auto green = "\x1B[32m";
constexpr static auto red = "\x1B[31m";
constexpr static auto yellow = "\x1B[33m";
constexpr static auto blue = "\x1B[34m";
constexpr static auto magenta = "\x1B[35m";
constexpr static auto cyan = "\x1B[36m";
constexpr static auto white = "\x1B[37m";
constexpr static auto normal = "\x1B[0m";

inline std::mutex &mutex() {
static std::mutex lock;
Expand Down
4 changes: 2 additions & 2 deletions libspider/common/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace spider {
return res;
}

int sprintf(char *str, size_t size, const char *format, ...) {
int snprintf(char *str, size_t size, const char *format, ...) {
va_list list;
va_start(list, format);
auto res = std::vsnprintf(str, size, format, list);
Expand All @@ -79,7 +79,7 @@ namespace spider {
return std::vfprintf(stream, format, list);
}

int sprintf(char *str, size_t size, const char *format, va_list list) {
int snprintf(char *str, size_t size, const char *format, va_list list) {
return std::vsnprintf(str, size, format, list);
}

Expand Down
4 changes: 2 additions & 2 deletions libspider/common/Printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ namespace spider {

int fprintf(FILE *stream, const char *format, ...);

int sprintf(char *str, size_t size, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, ...);

int printf(const char *format, ...);

int fprintf(FILE *stream, const char *format, va_list list);

int sprintf(char *str, size_t size, const char *format, va_list list);
int snprintf(char *str, size_t size, const char *format, va_list list);

int printf(const char *format, va_list list);
}
Expand Down
26 changes: 13 additions & 13 deletions libspider/containers/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <cstdint>
#include <vector>
#include <memory/memory.h>
#include <containers/array_handle.h>
#include <containers/array_view.h>

/* === Class definition === */

Expand All @@ -51,7 +51,7 @@ namespace spider {
* @tparam T Type of the container content.
*/
template<typename T>
class array : public array_handle<T> {
class array : public array_view<T> {
public:
using value_type = T;
using size_type = size_t;
Expand All @@ -72,7 +72,7 @@ namespace spider {
* @param stack Stack on which the array should be allocated.
* @param size Size of the array.
*/
explicit array(size_type size, StackID stack = StackID::GENERAL) : array_handle<T>(allocate<T>(stack, size),
explicit array(size_type size, StackID stack = StackID::GENERAL) : array_view<T>(allocate<T>(stack, size),
size) { }

/**
Expand All @@ -82,36 +82,36 @@ namespace spider {
* @param value Value to set to all the elements of the array.
*/
array(size_t size, const_reference value, StackID stack = StackID::GENERAL) : array(size, stack) {
array_handle<T>::assign(value);
array_view<T>::assign(value);
}

array(std::initializer_list<value_type> il, StackID stack = StackID::GENERAL) : array(il.size(), stack) {
std::copy(il.begin(), il.end(), array_handle<T>::begin());
std::copy(il.begin(), il.end(), array_view<T>::begin());
}

array() noexcept = default;

array(const array &other) : array(other.size_) {
std::copy(other.begin(), other.end(), array_handle<T>::begin());
std::copy(other.begin(), other.end(), array_view<T>::begin());
};

array(array &&other) noexcept: array() {
swap(*this, other);
}

array(T *data, size_type size) : array_handle<T>(data, size) { }
array(T *data, size_type size) : array_view<T>(data, size) { }

~array() {
deallocate(array_handle<T>::data_);
deallocate(array_view<T>::data_);
}

/* === Member functions === */

array &operator=(const array &other) {
deallocate(array_handle<T>::data_);
array_handle<T>::data_ = allocate<T>(other.size_);
array_handle<T>::size_ = other.size_;
std::copy(other.begin(), other.end(), array_handle<T>::begin());
deallocate(array_view<T>::data_);
array_view<T>::data_ = allocate<T>(other.size_);
array_view<T>::size_ = other.size_;
std::copy(other.begin(), other.end(), array_view<T>::begin());
return *this;
}

Expand All @@ -132,7 +132,7 @@ namespace spider {
inline friend void swap(array<T> &first, array<T> &second) noexcept {
/* == Do the swapping of the values == */
using std::swap;
swap(static_cast<array_handle<T> &>(first), static_cast<array_handle<T> &>(second));
swap(static_cast<array_view<T> &>(first), static_cast<array_view<T> &>(second));
}

/* === Non member functions === */
Expand Down
Loading
Loading