Skip to content

Commit

Permalink
Merge pull request #227 from uliegecsm/cleanup
Browse files Browse the repository at this point in the history
cleaning(simple-kernel-timer): promote `find_index` to `kp_shared.hpp`
  • Loading branch information
dalg24 authored Dec 28, 2023
2 parents 91d9df2 + 8bb7ffc commit 0becae4
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 0becae4

Please sign in to comment.