Skip to content

Commit b908680

Browse files
authored
Fix race condition in cpp metric tests. (#9058)
1 parent a5cd241 commit b908680

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/metric/elementwise_metric.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct EvalError {
217217
}
218218
}
219219
const char *Name() const {
220-
static std::string name;
220+
static thread_local std::string name;
221221
if (has_param_) {
222222
std::ostringstream os;
223223
os << "error";
@@ -315,7 +315,7 @@ struct EvalTweedieNLogLik {
315315
<< "tweedie variance power must be in interval [1, 2)";
316316
}
317317
const char *Name() const {
318-
static std::string name;
318+
static thread_local std::string name;
319319
std::ostringstream os;
320320
os << "tweedie-nloglik@" << rho_;
321321
name = os.str();

0 commit comments

Comments
 (0)