Skip to content

Update snitch and CI dependencies #19

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

Merged
merged 13 commits into from
Jan 19, 2023
Merged
6 changes: 3 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on: push

env:
EM_VERSION: 2.0.16
EM_VERSION: 2.0.34
EM_CACHE_FOLDER: 'emsdk-cache'
CODECOV_TOKEN: '99959e57-0b92-48b4-bf55-559d43d41b58'

Expand All @@ -28,7 +28,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand All @@ -46,7 +46,7 @@ jobs:

- name: Setup Emscripten
if: matrix.platform.compiler == 'em++'
uses: mymindstorm/setup-emsdk@v7
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
build_wasm/
build_clang/
doc/html/
oup.sublime-workspace
4 changes: 2 additions & 2 deletions oup.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"shell_cmd": "make -j12 oup_speed_benchmark",
},
{
"name": "snatch",
"shell_cmd": "make -j12 snatch",
"name": "snitch",
"shell_cmd": "make -j12 snitch",
},
],
"working_dir": "$folder/build",
Expand Down
10 changes: 5 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ endfunction()

include(FetchContent)

FetchContent_Declare(snatch
GIT_REPOSITORY https://github.com/cschreib/snatch.git
GIT_TAG v0.1.3)
FetchContent_MakeAvailable(snatch)
FetchContent_Declare(snitch
GIT_REPOSITORY https://github.com/cschreib/snitch.git
GIT_TAG v1.0.0)
FetchContent_MakeAvailable(snitch)

set(RUNTIME_TEST_FILES
${PROJECT_SOURCE_DIR}/tests/tests_common.cpp
Expand All @@ -61,7 +61,7 @@ set(RUNTIME_TEST_FILES

add_executable(oup_runtime_tests ${RUNTIME_TEST_FILES})
target_link_libraries(oup_runtime_tests PRIVATE oup::oup)
target_link_libraries(oup_runtime_tests PRIVATE snatch::snatch)
target_link_libraries(oup_runtime_tests PRIVATE snitch::snitch)
add_platform_definitions(oup_runtime_tests)

add_custom_target(oup_runtime_tests_run
Expand Down
36 changes: 18 additions & 18 deletions tests/memory_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <cstdio>
#include <stdexcept>

void* allocations[max_allocations];
void* allocations_array[max_allocations];
std::size_t allocations_bytes[max_allocations];
std::size_t num_allocations = 0u;
std::size_t size_allocations = 0u;
std::size_t double_delete = 0u;
bool memory_tracking = false;
bool force_next_allocation_failure = false;
volatile void* allocations[max_allocations];
volatile void* allocations_array[max_allocations];
volatile std::size_t allocations_bytes[max_allocations];
volatile std::size_t num_allocations = 0u;
volatile std::size_t size_allocations = 0u;
volatile std::size_t double_delete = 0u;
volatile bool memory_tracking = false;
volatile bool force_next_allocation_failure = false;

constexpr bool debug_alloc = false;
constexpr bool scramble_alloc = true;
Expand Down Expand Up @@ -93,8 +93,8 @@ void* allocate(std::size_t size, bool array, std::align_val_t align) {

allocations_bytes[num_allocations] = size;

++num_allocations;
size_allocations += size;
num_allocations = num_allocations + 1u;
size_allocations = size_allocations + size;
}

return p;
Expand All @@ -110,21 +110,21 @@ void deallocate(void* p, bool array, std::align_val_t align [[maybe_unused]]) {
}

if (memory_tracking) {
bool found = false;
void** allocations_type = array ? allocations_array : allocations;
bool found = false;
volatile void** allocations_type = array ? allocations_array : allocations;
for (std::size_t i = 0; i < num_allocations; ++i) {
if (allocations_type[i] == p) {
std::swap(allocations_type[i], allocations_type[num_allocations - 1]);
std::swap(allocations_bytes[i], allocations_bytes[num_allocations - 1]);
--num_allocations;
size_allocations -= allocations_bytes[num_allocations - 1];
found = true;
num_allocations = num_allocations - 1u;
size_allocations = size_allocations - allocations_bytes[num_allocations - 1];
found = true;
break;
}
}

if (!found) {
++double_delete;
double_delete = double_delete + 1u;
}
}

Expand Down Expand Up @@ -188,11 +188,11 @@ memory_tracker::~memory_tracker() noexcept {
::memory_tracking = false;
}

std::size_t memory_tracker::allocated() const {
std::size_t memory_tracker::allocated() const volatile {
return ::num_allocations - initial_allocations;
}

std::size_t memory_tracker::double_delete() const {
std::size_t memory_tracker::double_delete() const volatile {
return ::double_delete - initial_double_delete;
}

Expand Down
22 changes: 11 additions & 11 deletions tests/memory_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#include <new>

// Allocation tracker, to catch memory leaks and double delete
constexpr std::size_t max_allocations = 20'000;
extern void* allocations[max_allocations];
extern void* allocations_array[max_allocations];
extern std::size_t allocations_bytes[max_allocations];
extern std::size_t num_allocations;
extern std::size_t size_allocations;
extern std::size_t double_delete;
extern bool memory_tracking;
extern bool force_next_allocation_failure;
constexpr std::size_t max_allocations = 20'000;
extern volatile void* allocations[max_allocations];
extern volatile void* allocations_array[max_allocations];
extern volatile std::size_t allocations_bytes[max_allocations];
extern volatile std::size_t num_allocations;
extern volatile std::size_t size_allocations;
extern volatile std::size_t double_delete;
extern volatile bool memory_tracking;
extern volatile bool force_next_allocation_failure;

void* operator new(std::size_t size);

Expand Down Expand Up @@ -39,8 +39,8 @@ struct memory_tracker {
memory_tracker() noexcept;
~memory_tracker() noexcept;

std::size_t allocated() const;
std::size_t double_delete() const;
std::size_t allocated() const volatile;
std::size_t double_delete() const volatile;
};

struct fail_next_allocation {
Expand Down
49 changes: 24 additions & 25 deletions tests/runtime_tests_lifetime.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include "memory_tracker.hpp"
#include "testing.hpp"
#include "tests_common.hpp"

#include <algorithm>
#include <vector>

TEMPLATE_LIST_TEST_CASE("observer expiring scope", "[lifetime][owner][observer]", owner_types) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
observer_ptr<TestType> optr;
Expand All @@ -25,11 +24,11 @@ TEMPLATE_LIST_TEST_CASE("observer expiring scope", "[lifetime][owner][observer]"
}

CHECK_NO_LEAKS;
};
}

TEMPLATE_LIST_TEST_CASE(
"observer not expiring when owner moved", "[lifetime][owner][observer]", owner_types) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType outer_ptr;
Expand Down Expand Up @@ -59,10 +58,10 @@ TEMPLATE_LIST_TEST_CASE(
}

CHECK_NO_LEAKS;
};
}

TEMPLATE_LIST_TEST_CASE("observer expiring reset", "[lifetime][owner][observer]", owner_types) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
observer_ptr<TestType> optr;
Expand All @@ -82,12 +81,12 @@ TEMPLATE_LIST_TEST_CASE("observer expiring reset", "[lifetime][owner][observer]"
}

CHECK_NO_LEAKS;
};
}

TEMPLATE_LIST_TEST_CASE(
"release valid owner with observer", "[lifetime][release][owner][observer]", owner_types) {
if constexpr (!is_sealed<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
observer_ptr<TestType> optr;
Expand Down Expand Up @@ -126,14 +125,14 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"release valid owner with observer subobject",
"[lifetime][release][owner][observer]",
owner_types) {
if constexpr (!is_sealed<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
state_observer_ptr<TestType> optr;
Expand Down Expand Up @@ -170,11 +169,11 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"observer get and raw get", "[lifetime][get][raw_get][owner][observer]", owner_types) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
observer_ptr<TestType> optr;
Expand All @@ -196,14 +195,14 @@ TEMPLATE_LIST_TEST_CASE(
}

CHECK_NO_LEAKS;
};
}

TEMPLATE_LIST_TEST_CASE(
"object owning observer pointer to itself",
"[lifetime][cycles][owner][observer]",
owner_types) {
if constexpr (is_cyclic<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType ptr = make_pointer_deleter_1<TestType>();
Expand All @@ -214,12 +213,12 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"object owning observer pointer to other", "[lifetime][cycles][owner][observer]", owner_types) {
if constexpr (is_cyclic<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType ptr1 = make_pointer_deleter_1<TestType>();
Expand All @@ -232,14 +231,14 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"object owning observer pointer open chain",
"[lifetime][cycles][owner][observer]",
owner_types) {
if constexpr (is_cyclic<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType ptr1 = make_pointer_deleter_1<TestType>();
Expand All @@ -253,14 +252,14 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"object owning observer pointer open chain reversed",
"[lifetime][cycles][owner][observer]",
owner_types) {
if constexpr (is_cyclic<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType ptr1 = make_pointer_deleter_1<TestType>();
Expand All @@ -274,14 +273,14 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE(
"object owning observer pointer closed chain interleaved",
"[lifetime][cycles][owner][observer]",
owner_types) {
if constexpr (is_cyclic<TestType>) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
TestType ptr1 = make_pointer_deleter_1<TestType>();
Expand All @@ -298,10 +297,10 @@ TEMPLATE_LIST_TEST_CASE(

CHECK_NO_LEAKS;
}
};
}

TEMPLATE_LIST_TEST_CASE("pointers in vector", "[lifetime][array][owner][observer]", owner_types) {
memory_tracker mem_track;
volatile memory_tracker mem_track;

{
std::vector<TestType> vec_own;
Expand Down Expand Up @@ -346,4 +345,4 @@ TEMPLATE_LIST_TEST_CASE("pointers in vector", "[lifetime][array][owner][observer
}

CHECK_NO_LEAKS;
};
}
Loading