Skip to content

Commit 622cb25

Browse files
authored
A few more minor optimizations (LLNL#462)
1 parent 2e31125 commit 622cb25

File tree

7 files changed

+22
-46
lines changed

7 files changed

+22
-46
lines changed

include/caliper/Annotation.h

+14-11
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ namespace cali
2424
/// \brief Pre-defined function annotation class
2525
class Function
2626
{
27-
private:
28-
29-
// Do not copy Function objects: will double-end things
30-
Function(const Function&);
31-
Function& operator = (const Function&);
32-
3327
public:
3428

3529
Function(const char* name);
30+
31+
Function(const Function&) = delete;
32+
Function& operator = (const Function&) = delete;
33+
3634
~Function();
3735
};
3836

@@ -150,13 +148,13 @@ class Annotation
150148
class Guard {
151149
Impl* pI;
152150

153-
Guard(const Guard&);
154-
Guard& operator = (const Guard&);
155-
156151
public:
157152

158153
Guard(Annotation& a);
159154

155+
Guard(const Guard&) = delete;
156+
Guard& operator = (const Guard&) = delete;
157+
160158
~Guard();
161159
};
162160

@@ -179,8 +177,13 @@ class Annotation
179177
/// \copydoc cali::Annotation::begin(int)
180178
Annotation& begin(double data);
181179
/// \copydoc cali::Annotation::begin(int)
182-
Annotation& begin(const char* data);
183-
Annotation& begin(cali_attr_type type, void* data, uint64_t size);
180+
Annotation& begin(const char* data) {
181+
return begin(Variant(data));
182+
}
183+
/// \copydoc cali::Annotation::begin(int)
184+
Annotation& begin(cali_attr_type type, void* data, uint64_t size) {
185+
return begin(Variant(type, data, size));
186+
}
184187
/// \copydoc cali::Annotation::begin(int)
185188
Annotation& begin(const Variant& data);
186189

include/caliper/Caliper.h

-3
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,6 @@ class Caliper : public CaliperMetadataAccessInterface
520520
/// \name Context tree manipulation and metadata access
521521
/// \{
522522

523-
/// \brief Return the total number of attributes
524-
size_t num_attributes() const;
525-
526523
/// \brief Return \a true if the attribute with name \a name exists
527524
bool attribute_exists(const std::string& name) const;
528525

include/caliper/common/Node.h

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class Node : public util::LockfreeIntrusiveTree<Node>
4444

4545
Node& operator = (const Node&) = delete;
4646

47-
~Node();
48-
4947
/// \brief Check if the node's attribute and value are equal to
5048
/// \a attr and \a v
5149
bool equals(cali_id_t attr, const Variant& v) const {

src/caliper/Annotation.cpp

+7-15
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct Annotation::Impl {
126126
std::vector<Variant> m_metadata_values;
127127
int m_opt;
128128
std::atomic<int> m_refcount;
129+
129130
Impl(const std::string& name, MetadataListType metadata, int opt)
130131
: m_attr(nullptr),
131132
m_name(name),
@@ -151,17 +152,18 @@ struct Annotation::Impl {
151152
~Impl() {
152153
delete m_attr.load();
153154
}
155+
154156
void begin(const Variant& data) {
155157
Caliper c;
156-
Attribute attr = get_attribute(c, data.type(), m_metadata_keys, m_metadata_values);
158+
Attribute attr = get_attribute(c, data.type());
157159

158160
if ((attr.type() == data.type()) && attr.type() != CALI_TYPE_INV)
159161
c.begin(attr, data);
160162
}
161163

162164
void set(const Variant& data) {
163165
Caliper c;
164-
Attribute attr = get_attribute(c, data.type(), m_metadata_keys, m_metadata_values);
166+
Attribute attr = get_attribute(c, data.type());
165167

166168
if ((attr.type() == data.type()) && attr.type() != CALI_TYPE_INV)
167169
c.set(attr, data);
@@ -173,13 +175,13 @@ struct Annotation::Impl {
173175
c.end(get_attribute(c));
174176
}
175177

176-
Attribute get_attribute(Caliper& c, cali_attr_type type = CALI_TYPE_INV, const std::vector<cali::Attribute>& attrs = {}, const std::vector<cali::Variant>& values = {}) {
178+
Attribute get_attribute(Caliper& c, cali_attr_type type = CALI_TYPE_INV) {
177179
Attribute* attr_p = m_attr.load();
178180

179181
if (!attr_p) {
180182
Attribute* new_attr = type == CALI_TYPE_INV ?
181183
new Attribute(c.get_attribute(m_name)) :
182-
new Attribute(c.create_attribute(m_name, type, m_opt,attrs.size(),attrs.data(),values.data()));
184+
new Attribute(c.create_attribute(m_name, type, m_opt, m_metadata_keys.size(), m_metadata_keys.data(), m_metadata_values.data()));
183185

184186
// Don't store invalid attribute in shared pointer
185187
if (*new_attr == Attribute::invalid)
@@ -281,16 +283,6 @@ Annotation& Annotation::begin(double data)
281283
return begin(Variant(data));
282284
}
283285

284-
Annotation& Annotation::begin(const char* data)
285-
{
286-
return begin(Variant(data));
287-
}
288-
289-
Annotation& Annotation::begin(cali_attr_type type, void* data, uint64_t size)
290-
{
291-
return begin(Variant(type, data, size));
292-
}
293-
294286
Annotation& Annotation::begin(const Variant& data)
295287
{
296288
pI->begin(data);
@@ -319,7 +311,7 @@ Annotation& Annotation::set(double data)
319311

320312
Annotation& Annotation::set(const char* data)
321313
{
322-
return set(Variant(CALI_TYPE_STRING, data, strlen(data)));
314+
return set(Variant(data));
323315
}
324316

325317
Annotation& Annotation::set(cali_attr_type type, void* data, uint64_t size)

src/caliper/Caliper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ Caliper::memory_region_end(Channel* channel, const void* ptr)
12981298
// --- Generic entry API
12991299

13001300
void
1301-
Caliper::make_record(size_t n, const Attribute* attr, const Variant* value, SnapshotBuilder& rec, Node* parent)
1301+
Caliper::make_record(size_t n, const Attribute attr[], const Variant value[], SnapshotBuilder& rec, Node* parent)
13021302
{
13031303
std::lock_guard<::siglock>
13041304
g(sT->lock);

src/common/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set(CALIPER_COMMON_SOURCES
44
CompressedSnapshotRecord.cpp
55
Entry.cpp
66
Log.cpp
7-
Node.cpp
87
NodeBuffer.cpp
98
OutputStream.cpp
109
RuntimeConfig.cpp

src/common/Node.cpp

-13
This file was deleted.

0 commit comments

Comments
 (0)