Skip to content

Commit cfc5578

Browse files
committed
Drop support for runtime zone names
1 parent 0347c88 commit cfc5578

2 files changed

Lines changed: 23 additions & 47 deletions

File tree

src/ipc/potentials/potential.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ double Potential<TCollisions>::operator()(
4040
Eigen::ConstRef<Eigen::MatrixXd> X) const
4141
{
4242
assert(X.rows() == mesh.num_vertices());
43-
IPC_TOOLKIT_PROFILE_BLOCK(this->name() + "::operator()");
43+
IPC_TOOLKIT_PROFILE_BLOCK("Potential<T>::operator()");
4444

4545
return tbb::parallel_reduce(
4646
tbb::blocked_range<size_t>(size_t(0), collisions.size()), 0.0,
@@ -63,7 +63,7 @@ Eigen::VectorXd Potential<TCollisions>::gradient(
6363
Eigen::ConstRef<Eigen::MatrixXd> X) const
6464
{
6565
assert(X.rows() == mesh.num_vertices());
66-
IPC_TOOLKIT_PROFILE_BLOCK(this->name() + "::gradient()");
66+
IPC_TOOLKIT_PROFILE_BLOCK("Potential<T>::gradient()");
6767

6868
if (collisions.empty()) {
6969
return Eigen::VectorXd::Zero(X.size());
@@ -74,7 +74,7 @@ Eigen::VectorXd Potential<TCollisions>::gradient(
7474
tbb::combinable<Eigen::VectorXd> grad(Eigen::VectorXd::Zero(X.size()));
7575

7676
{
77-
IPC_TOOLKIT_PROFILE_BLOCK("compute local gradients");
77+
IPC_TOOLKIT_PROFILE_BLOCK("Compute Local Gradients");
7878
tbb::parallel_for(size_t(0), collisions.size(), [&](size_t i) {
7979
const TCollision& collision = collisions[i];
8080

@@ -88,7 +88,7 @@ Eigen::VectorXd Potential<TCollisions>::gradient(
8888
}
8989

9090
{
91-
IPC_TOOLKIT_PROFILE_BLOCK("combine local gradients");
91+
IPC_TOOLKIT_PROFILE_BLOCK("Combine Local Gradients");
9292
return grad.combine([](const Eigen::VectorXd& a,
9393
const Eigen::VectorXd& b) { return a + b; });
9494
}
@@ -102,7 +102,7 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
102102
const PSDProjectionMethod project_hessian_to_psd) const
103103
{
104104
assert(X.rows() == mesh.num_vertices());
105-
IPC_TOOLKIT_PROFILE_BLOCK(this->name() + "::hessian()");
105+
IPC_TOOLKIT_PROFILE_BLOCK("Potential<T>::gradient()");
106106

107107
if (collisions.empty()) {
108108
return Eigen::SparseMatrix<double>(X.size(), X.size());
@@ -129,15 +129,15 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
129129

130130
MatrixMaxNd local_hess;
131131
{
132-
IPC_TOOLKIT_PROFILE_BLOCK("compute local hessian");
132+
IPC_TOOLKIT_PROFILE_BLOCK("Compute Local Hessian");
133133
local_hess = this->hessian(
134134
collision, collision.dof(X, edges, faces),
135135
project_hessian_to_psd);
136136
}
137137

138138
{
139139
IPC_TOOLKIT_PROFILE_BLOCK(
140-
"map local hessian to global triplets");
140+
"Map Local Hessian to Global Triplets");
141141
local_hessian_to_global_triplets(
142142
local_hess, collision.vertex_ids(edges, faces), dim,
143143
*(hess_triplets.cache), mesh.num_vertices());
@@ -152,7 +152,7 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
152152
// storage
153153

154154
{
155-
IPC_TOOLKIT_PROFILE_BLOCK("prune local storages");
155+
IPC_TOOLKIT_PROFILE_BLOCK("Prune Local Storages");
156156
tbb::parallel_for_each(
157157
storage.begin(), storage.end(),
158158
[](const auto& local_storage) { local_storage.cache->prune(); });
@@ -188,13 +188,13 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
188188

189189
// Allocate triplets
190190
{
191-
IPC_TOOLKIT_PROFILE_BLOCK("allocate triplets");
191+
IPC_TOOLKIT_PROFILE_BLOCK("Allocate Triplets");
192192
triplets.resize(triplet_count);
193193
}
194194

195195
// Parallel copy into triplets
196196
{
197-
IPC_TOOLKIT_PROFILE_BLOCK("parallel copy into triplets");
197+
IPC_TOOLKIT_PROFILE_BLOCK("Parallel Copy into Triplets");
198198
tbb::parallel_for(size_t(0), storage.size(), [&](size_t i) {
199199
const SparseMatrixCache& cache =
200200
dynamic_cast<const SparseMatrixCache&>(
@@ -214,7 +214,7 @@ Eigen::SparseMatrix<double> Potential<TCollisions>::hessian(
214214

215215
// Sort and assemble
216216
{
217-
IPC_TOOLKIT_PROFILE_BLOCK("assemble hessian from triplets");
217+
IPC_TOOLKIT_PROFILE_BLOCK("Assemble Hessian from Triplets");
218218
hess.setFromTriplets(triplets.begin(), triplets.end());
219219
}
220220

src/ipc/utils/profiler.hpp

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
#ifdef IPC_TOOLKIT_WITH_TRACY
66
#include <tracy/Tracy.hpp>
7+
#else
8+
// Empty macro to avoid compilation errors when Tracy is not enabled.
9+
#define ZoneScopedN(name) ((void)0)
710
#endif
811

912
#include <string>
1013

11-
// Helper macro to stringify/paste after expansion
12-
#define IPC_TOOLKIT_PROFILE_BLOCK_CONCAT_IMPL(a, b) a##b
13-
#define IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(a, b) \
14-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT_IMPL(a, b)
15-
1614
#ifdef IPC_TOOLKIT_WITH_PROFILER
1715

1816
// clang-format off
@@ -26,25 +24,15 @@
2624
#include <iostream>
2725
#include <thread>
2826

29-
#if defined(IPC_TOOLKIT_WITH_TRACY) && defined(TRACY_ENABLE)
30-
// ZoneScoped + ZoneName supports both compile-time string literals and
31-
// runtime std::string expressions, unlike ZoneScopedN which requires a
32-
// constexpr const char*.
33-
#define IPC_TOOLKIT_PROFILE_BLOCK(...) \
34-
const std::string IPC_TOOLKIT_PROFILE_BLOCK_CONCAT( \
35-
__ipc_zone_name_, __LINE__)(__VA_ARGS__); \
36-
ipc::ProfilePoint IPC_TOOLKIT_PROFILE_BLOCK_CONCAT( \
37-
__ipc_profile_point_, __LINE__)( \
38-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(__ipc_zone_name_, __LINE__)); \
39-
ZoneScoped; \
40-
ZoneName( \
41-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(__ipc_zone_name_, __LINE__).c_str(), \
42-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(__ipc_zone_name_, __LINE__).size())
43-
#else
27+
// Helper macro to stringify/paste after expansion
28+
#define IPC_TOOLKIT_PROFILE_BLOCK_CONCAT_IMPL(a, b) a##b
29+
#define IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(a, b) \
30+
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT_IMPL(a, b)
31+
4432
#define IPC_TOOLKIT_PROFILE_BLOCK(...) \
4533
ipc::ProfilePoint IPC_TOOLKIT_PROFILE_BLOCK_CONCAT( \
46-
__ipc_profile_point_, __COUNTER__)(__VA_ARGS__)
47-
#endif
34+
__ipc_profile_point_, __COUNTER__)(__VA_ARGS__); \
35+
ZoneScopedN(__VA_ARGS__)
4836

4937
namespace ipc {
5038

@@ -152,21 +140,9 @@ template <class Timer = ChronoTimer> class ProfilePoint {
152140

153141
} // namespace ipc
154142

155-
#elif defined(IPC_TOOLKIT_WITH_TRACY) && defined(TRACY_ENABLE)
156-
157-
// Custom profiler disabled: Tracy zone only.
158-
// ZoneScoped + ZoneName supports runtime strings, unlike ZoneScopedN.
159-
#define IPC_TOOLKIT_PROFILE_BLOCK(...) \
160-
const std::string IPC_TOOLKIT_PROFILE_BLOCK_CONCAT( \
161-
__ipc_zone_name_, __LINE__)(__VA_ARGS__); \
162-
ZoneScoped; \
163-
ZoneName( \
164-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(__ipc_zone_name_, __LINE__).c_str(), \
165-
IPC_TOOLKIT_PROFILE_BLOCK_CONCAT(__ipc_zone_name_, __LINE__).size())
166-
167143
#else
168144

169-
// No profiling enabled: no-op.
170-
#define IPC_TOOLKIT_PROFILE_BLOCK(...)
145+
// Custom profiler disabled: Tracy zone only.
146+
#define IPC_TOOLKIT_PROFILE_BLOCK(...) ZoneScopedN(__VA_ARGS__)
171147

172148
#endif

0 commit comments

Comments
 (0)