Skip to content

Commit

Permalink
cleaning(simple-kernel-timer): promote find_index to kp_shared.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
romintomasetti committed Dec 28, 2023
1 parent 91d9df2 commit 8bb7ffc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
13 changes: 0 additions & 13 deletions profiling/simple-kernel-timer/kp_json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ inline void write_json(std::ostream& os, KernelPerformanceInfo const& kp,
os << indent << '}';
}

int find_index(std::vector<KernelPerformanceInfo*>& kernels,
const char* kernelName) {
for (unsigned int i = 0; i < kernels.size(); i++) {
KernelPerformanceInfo* nextKernel = kernels[i];

if (strcmp(nextKernel->getName(), kernelName) == 0) {
return i;
}
}

return -1;
}

int main(int argc, char* argv[]) {
if (argc == 1) {
fprintf(stderr, "Did you specify any data files on the command line!\n");
Expand Down
13 changes: 0 additions & 13 deletions profiling/simple-kernel-timer/kp_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@

using namespace KokkosTools::KernelTimer;

int find_index(std::vector<KernelPerformanceInfo*>& kernels,
const char* kernelName) {
for (unsigned int i = 0; i < kernels.size(); i++) {
KernelPerformanceInfo* nextKernel = kernels[i];

if (strcmp(nextKernel->getName(), kernelName) == 0) {
return i;
}
}

return -1;
}

int main(int argc, char* argv[]) {
if (argc == 1) {
fprintf(stderr, "Did you specify any data files on the command line!\n");
Expand Down
12 changes: 12 additions & 0 deletions profiling/simple-kernel-timer/kp_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <map>
#include <memory>
#include <vector>

#include "kp_kernel_info.h"

namespace KokkosTools::KernelTimer {
Expand All @@ -39,6 +41,16 @@ inline bool compareKernelPerformanceInfo(KernelPerformanceInfo* left,
return left->getTime() > right->getTime();
};

inline int find_index(const std::vector<KernelPerformanceInfo*>& kernels,
const char* kernelName) {
for (unsigned int i = 0; i < kernels.size(); i++) {
if (strcmp(kernels[i]->getName(), kernelName) == 0) {
return i;
}
}
return -1;
}

} // namespace KokkosTools::KernelTimer

#endif // _H_KOKKOSP_KERNEL_SHARED

0 comments on commit 8bb7ffc

Please sign in to comment.