Skip to content

Commit 35bd6b5

Browse files
committed
Add whitelist of regions with no region enter events
Avoids confusing warning when it is known that no region enter event can be recorded. This is true for the threading::bootstrap methods as they are called right after creating a new thread but before the instrumenter is enabled Fixes #87
1 parent 532373d commit 35bd6b5

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/scorepy/events.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "events.hpp"
2+
#include <algorithm>
3+
#include <array>
24
#include <iostream>
35
#include <scorep/SCOREP_User_Functions.h>
46
#include <scorep/SCOREP_User_Variables.h>
@@ -33,6 +35,11 @@ void region_begin(const std::string& region_name, std::string module, std::strin
3335
SCOREP_User_RegionEnter(handle.value);
3436
}
3537

38+
/// Region names that are known to have no region enter event and should not report an error
39+
/// on region exit
40+
static const std::array<std::string, 2> EXIT_REGION_WHITELIST = { "threading:_bootstrap_inner",
41+
"threading:_bootstrap" };
42+
3643
void region_end(const std::string& region_name)
3744
{
3845
const auto itRegion = regions.find(region_name);
@@ -46,6 +53,12 @@ void region_end(const std::string& region_name)
4653
static SCOREP_User_ParameterHandle scorep_param = SCOREP_USER_INVALID_PARAMETER;
4754
static bool error_printed = false;
4855

56+
if (std::find(EXIT_REGION_WHITELIST.begin(), EXIT_REGION_WHITELIST.end(), region_name) !=
57+
EXIT_REGION_WHITELIST.end())
58+
{
59+
return;
60+
}
61+
4962
if (error_region.value == SCOREP_USER_INVALID_REGION)
5063
{
5164
SCOREP_User_RegionInit(&error_region.value, NULL, &SCOREP_User_LastFileHandle,

test/test_scorep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def test_threads(scorep_env, instrumenter):
307307
["--nocompiler", "--instrumenter-type=" + instrumenter],
308308
env=scorep_env)
309309

310-
# assert std_err == "" TODO: Readd when issue #87 is resolved
310+
assert std_err == ""
311311
assert "hello world\n" in std_out
312312
assert "Thread 0 started\n" in std_out
313313
assert "Thread 1 started\n" in std_out

0 commit comments

Comments
 (0)