-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathKokkosMetadataService.cpp
More file actions
88 lines (70 loc) · 2.31 KB
/
Copy pathKokkosMetadataService.cpp
File metadata and controls
88 lines (70 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// Created by Poliakoff, David Zoeller on 4/21/21.
//
#include "caliper/CaliperService.h"
#include "caliper/Caliper.h"
#include "../../caliper/MemoryPool.h"
#include "caliper/common/Log.h"
#include "caliper/common/RuntimeConfig.h"
#include "caliper/Annotation.h"
#include <iterator>
#include <cstdint>
#include "types.hpp"
#include "adiak.hpp"
using namespace cali;
namespace {
class KokkosAdiak {
static const ConfigSet::Entry s_configdata[];
KokkosAdiak(Caliper *c, Channel *chn) {
adiak_init(nullptr);
adiak::user();
adiak::launchdate();
adiak::executablepath();
adiak::libraries();
adiak::cmdline();
adiak::clustername();
adiak::jobsize();
}
public:
void declare(const char* key, const char* value){
std::string parseme(value);
try {
size_t end;
float v = std::stof(parseme,&end);
adiak::value(key, v);
return;
}
catch(std::invalid_argument){
}
try {
size_t end;
int i = std::stoi(parseme,&end);
adiak::value(key, i);
return;
}
catch(std::invalid_argument){
}
adiak::value(key,value);
}
static void kokkosadiak_register(Caliper *c, Channel *chn) {
auto *instance = new KokkosAdiak(c, chn);
chn->events().post_init_evt.connect(
[instance](Caliper *c, Channel *chn) {
kokkosp_callbacks.kokkosp_declare_metadata.connect([&](const char* name, const char* value){
instance->declare(name,value);
});
});
chn->events().finish_evt.connect(
[instance](Caliper*, Channel*){
delete instance;
});
Log(1).stream() << chn->name() << ": Registered kokkosadiak service" << std::endl;
}
};
const ConfigSet::Entry KokkosAdiak::s_configdata[] = {
ConfigSet::Terminator
};
} // namespace [anonymous]
namespace cali {
CaliperService kokkosadiak_service{"kokkosadiak", ::KokkosAdiak::kokkosadiak_register};
}