Skip to content

Commit

Permalink
Profiling: Add empty function defs when profiling disabled
Browse files Browse the repository at this point in the history
This commit to address issue kokkos#1424
Requested so user codes that include profiling hooks so user
codes/packages do not need to if-guard
  • Loading branch information
ndellingwood committed Feb 21, 2018
1 parent 91e8fa0 commit 81de9b5
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
40 changes: 40 additions & 0 deletions core/src/impl/Kokkos_Profiling_Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,45 @@ void finalize() {

#else
void KOKKOS_CORE_SRC_IMPL_PROFILING_INTERFACE_PREVENT_LINK_ERROR() {}

#include <impl/Kokkos_Profiling_Interface.hpp>
#include <cstring>
namespace Kokkos {
namespace Profiling {

bool profileLibraryLoaded() {}


void beginParallelFor(const std::string& , const uint32_t , uint64_t* ) {}
void endParallelFor(const uint64_t ) {}
void beginParallelScan(const std::string& , const uint32_t , uint64_t* ) {}
void endParallelScan(const uint64_t ) {}
void beginParallelReduce(const std::string& , const uint32_t , uint64_t* ) {}
void endParallelReduce(const uint64_t ) {}

void pushRegion(const std::string& ) {}
void popRegion() {}
void createProfileSection(const std::string& , uint32_t* ) {}
void startSection(const uint32_t ) {}
void stopSection(const uint32_t ) {}
void destroyProfileSection(const uint32_t ) {}

void markEvent(const std::string& ) {}

void allocateData(const SpaceHandle , const std::string , const void* , const uint64_t ) {}
void deallocateData(const SpaceHandle , const std::string , const void* , const uint64_t ) {}

void beginDeepCopy(const SpaceHandle , const std::string , const void* ,
const SpaceHandle , const std::string , const void* ,
const uint64_t ) {}
void endDeepCopy() {}

void initialize() {}
void finalize() {}

}
}


#endif

54 changes: 49 additions & 5 deletions core/src/impl/Kokkos_Profiling_Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,20 @@
#define KOKKOSP_INTERFACE_HPP

#include <Kokkos_Macros.hpp>

#if defined(KOKKOS_ENABLE_PROFILING)

#include <cinttypes>
#include <cstddef>
#include <Kokkos_Core_fwd.hpp>
#include <string>
#include <cinttypes>

#include <impl/Kokkos_Profiling_DeviceInfo.hpp>
#include <dlfcn.h>
#include <iostream>
#include <cstdlib>


#if defined(KOKKOS_ENABLE_PROFILING)

#include <impl/Kokkos_Profiling_DeviceInfo.hpp>

#define KOKKOSP_INTERFACE_VERSION 20171029

namespace Kokkos {
Expand Down Expand Up @@ -128,6 +129,49 @@ void finalize();
}
}

#else
namespace Kokkos {
namespace Profiling {

struct SpaceHandle {
SpaceHandle(const char* space_name);
char name[64];
};


bool profileLibraryLoaded();


void beginParallelFor(const std::string& , const uint32_t , uint64_t* );
void endParallelFor(const uint64_t );
void beginParallelScan(const std::string& , const uint32_t , uint64_t* );
void endParallelScan(const uint64_t );
void beginParallelReduce(const std::string& , const uint32_t , uint64_t* );
void endParallelReduce(const uint64_t );

void pushRegion(const std::string& );
void popRegion();
void createProfileSection(const std::string& , uint32_t* );
void startSection(const uint32_t );
void stopSection(const uint32_t );
void destroyProfileSection(const uint32_t );

void markEvent(const std::string& );

void allocateData(const SpaceHandle , const std::string , const void* , const uint64_t );
void deallocateData(const SpaceHandle , const std::string , const void* , const uint64_t );

void beginDeepCopy(const SpaceHandle , const std::string , const void* ,
const SpaceHandle , const std::string , const void* ,
const uint64_t );
void endDeepCopy();

void initialize();
void finalize();

}
}

#endif
#endif

0 comments on commit 81de9b5

Please sign in to comment.