Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
env_settings cleanup fix (#206)
Browse files Browse the repository at this point in the history
* fixes deleting env_settings on main thread when malloc/free wrapping via gotcha is activated
* fix to cupti_pcsampling compilation
* tweaks to some tests which fail in windows linux subsystem
* bumped version to 3.2.0rc3

- fixed free corruption when deleting env_settings and mallocp is enabled
- increased the util tolerance in timing_tests
- fixed cache_tests.io in Windows Linux Subsystem (/proc/<PID>/io not available)
  • Loading branch information
jrmadsen authored Jun 28, 2021
1 parent ac107eb commit cf30c23
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0.rc2
3.2.0.rc3
3 changes: 3 additions & 0 deletions source/tests/cache_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class cache_tests : public ::testing::Test
trait::runtime_enabled<gpu_roofline_flops>::set(false);
trait::runtime_enabled<gpu_roofline_sp_flops>::set(false);
trait::runtime_enabled<gpu_roofline_dp_flops>::set(false);
trait::runtime_enabled<cupti_pcsampling>::set(false);
}

static void extra_teardown()
Expand Down Expand Up @@ -559,6 +560,8 @@ get_value(Arg&)
#if defined(TIMEMORY_LINUX)
TEST_F(cache_tests, io)
{
if(!std::ifstream{ TIMEMORY_JOIN('/', "/proc", tim::process::get_target_id(), "io") })
return;
using io_bundle_t =
tim::component_tuple<read_bytes, read_char, written_bytes, written_char>;
using timing_t = tim::auto_tuple<wall_clock>;
Expand Down
2 changes: 1 addition & 1 deletion source/tests/timing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace tim::component;
using mutex_t = std::mutex;
using lock_t = std::unique_lock<mutex_t>;

static const double util_tolerance = 5.0;
static const double util_tolerance = 12.5;
static const double timer_tolerance = 0.025;

#define CHECK_AVAILABLE(type) \
Expand Down
7 changes: 4 additions & 3 deletions source/timemory/components/cupti/backends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
# include "timemory/backends/cupti.hpp"
# include <cuda.h>
# include <cupti.h>
# if defined(TIMEMORY_USE_CUPTI_PCSAMPLING)
# include <cupti_pcsampling.h>
# endif
#endif

#if defined(TIMEMORY_USE_CUPTI_PCSAMPLING)
# include <cupti_pcsampling.h>
#endif

#include <array>
Expand Down
15 changes: 5 additions & 10 deletions source/timemory/environment/definition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,17 @@ TIMEMORY_ENVIRONMENT_LINKAGE(tim::env_settings*)
env_settings::instance()
{
static std::atomic<int> _count{ 0 };
static env_settings* _instance = new env_settings();
static thread_local int _id = _count++;
static env_settings _instance{};
static thread_local int _id = _count++;
static thread_local env_settings* _local =
(_id == 0) ? _instance : new env_settings{ _instance, _id };
(_id == 0) ? (&_instance) : new env_settings{ &_instance, _id };
static thread_local auto _ldtor = scope::destructor{ []() {
if(_local == _instance)
_instance = nullptr;
if(_local == &_instance || _id == 0)
return;
delete _local;
_local = nullptr;
} };
static auto _gdtor = scope::destructor{ []() {
delete _instance;
_instance = nullptr;
} };
return _local;
(void) _gdtor;
(void) _ldtor;
}
//
Expand Down
3 changes: 3 additions & 0 deletions source/timemory/storage/declaration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,9 @@ struct storage_deleter : public std::default_delete<StorageType>

void operator()(StorageType* ptr)
{
// if(ptr == nullptr)
// return;

StorageType* master = singleton_t::master_instance_ptr();
std::thread::id master_tid = singleton_t::master_thread_id();
std::thread::id this_tid = std::this_thread::get_id();
Expand Down

0 comments on commit cf30c23

Please sign in to comment.