Skip to content

Commit

Permalink
Merge pull request #190 from masterleinad/fix_warnings
Browse files Browse the repository at this point in the history
FIx warnings in all tools built in the CI
  • Loading branch information
crtrott authored May 4, 2023
2 parents 4a976b2 + ef37128 commit 7ab2900
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/simple-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
# The Kokkos Tools systemtap connector requires 'dtrace'
sudo apt update
sudo apt --yes --no-install-recommends install systemtap-sdt-dev
cmake -B build
cmake -B build -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror"
cmake --build build
cmake --install build --prefix ${PWD}/install
2 changes: 1 addition & 1 deletion common/kernel-filter/kp_kernel_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ extern "C" void kokkosp_init_library(const int loadSeq,
char* profileLibrary = getenv("KOKKOS_PROFILE_LIBRARY");
char* envBuffer =
(char*)malloc(sizeof(char) * (strlen(profileLibrary) + 1));
sprintf(envBuffer, "%s", profileLibrary);
strcpy(envBuffer, profileLibrary);

char* nextLibrary = strtok(envBuffer, ";");

Expand Down
30 changes: 18 additions & 12 deletions common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace KokkosTools {
namespace Sampler {
static uint64_t uniqID = 0;
static uint64_t kernelCounter = 0;
static uint64_t kernelSampleSkip = 101;
static int tool_verbosity = 0;
static int tool_globFence = 0;
Expand Down Expand Up @@ -65,7 +64,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
}

char* envBuffer = (char*)malloc(sizeof(char) * (strlen(profileLibrary) + 1));
sprintf(envBuffer, "%s", profileLibrary);
strcpy(envBuffer, profileLibrary);

char* nextLibrary = strtok(envBuffer, ";");

Expand Down Expand Up @@ -135,8 +134,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,

free(envBuffer);

kernelCounter = 0;
uniqID = 1;
uniqID = 1;

const char* tool_sample = getenv("KOKKOS_TOOLS_SAMPLER_SKIP");
if (NULL != tool_sample) {
Expand All @@ -148,15 +146,18 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
}
}

void kokkosp_finalize_library() {}
void kokkosp_finalize_library() {
if (NULL != finalizeProfileLibrary) (*finalizeProfileLibrary)();
}

void kokkosp_begin_parallel_for(const char* name, const uint32_t devID,
uint64_t* kID) {
*kID = uniqID++;

if (((*kID) % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-begin function...\n", *kID);
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}

if (NULL != beginForCallee) {
Expand All @@ -168,7 +169,8 @@ void kokkosp_begin_parallel_for(const char* name, const uint32_t devID,
void kokkosp_end_parallel_for(const uint64_t kID) {
if ((kID % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-end function...\n", kID);
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
}

if (NULL != endForCallee) {
Expand All @@ -183,7 +185,8 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,

if (((*kID) % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-begin function...\n", *kID);
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}

if (NULL != beginScanCallee) {
Expand All @@ -195,7 +198,8 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
void kokkosp_end_parallel_scan(const uint64_t kID) {
if ((kID % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-end function...\n", kID);
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
}

if (NULL != endScanCallee) {
Expand All @@ -210,7 +214,8 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID,

if (((*kID) % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-begin function...\n", *kID);
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}

if (NULL != beginReduceCallee) {
Expand All @@ -222,7 +227,8 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID,
void kokkosp_end_parallel_reduce(const uint64_t kID) {
if ((kID % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %lu calling child-end function...\n", kID);
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
}

if (NULL != endReduceCallee) {
Expand All @@ -238,7 +244,7 @@ extern "C" {

namespace impl = KokkosTools::Sampler;

EXPOSE_TOOL_SETTINGS(kokkosp_request_tool_settings)
EXPOSE_TOOL_SETTINGS(impl::kokkosp_request_tool_settings)
EXPOSE_INIT(impl::kokkosp_init_library)
EXPOSE_FINALIZE(impl::kokkosp_finalize_library)
EXPOSE_BEGIN_PARALLEL_FOR(impl::kokkosp_begin_parallel_for)
Expand Down
2 changes: 1 addition & 1 deletion debugging/kernel-logger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_library(kp_kernel_logger ${KOKKOSTOOLS_LIBRARY_MODE} kp_kernel_logger.cpp)
add_library(kp_kernel_logger ${KOKKOSTOOLS_LIBRARY_MODE} kp_kernel_logger.cpp)
40 changes: 22 additions & 18 deletions debugging/kernel-logger/kp_kernel_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ int kokkosp_print_region_stack() {

extern "C" void kokkosp_init_library(const int loadSeq,
const uint64_t interfaceVer,
const uint32_t devInfoCount,
void* deviceInfo) {
const uint32_t /*devInfoCount*/,
void* /*deviceInfo*/) {
printf(
"KokkosP: Kernel Logger Library Initialized (sequence is %d, version: "
"%llu)\n",
loadSeq, interfaceVer);
loadSeq, (unsigned long long)(interfaceVer));
uniqID = 0;
}

Expand All @@ -71,7 +71,7 @@ extern "C" void kokkosp_begin_parallel_for(const char* name,
printf(
"KokkosP: Executing parallel-for kernel on device %d with unique "
"execution identifier %llu\n",
devID, *kID);
devID, (unsigned long long)(*kID));

int level = kokkosp_print_region_stack();
kokkosp_print_region_stack_indent(level);
Expand All @@ -80,7 +80,8 @@ extern "C" void kokkosp_begin_parallel_for(const char* name,
}

extern "C" void kokkosp_end_parallel_for(const uint64_t kID) {
printf("KokkosP: Execution of kernel %llu is completed.\n", kID);
printf("KokkosP: Execution of kernel %llu is completed.\n",
(unsigned long long)(kID));
}

extern "C" void kokkosp_begin_parallel_scan(const char* name,
Expand All @@ -91,16 +92,17 @@ extern "C" void kokkosp_begin_parallel_scan(const char* name,
printf(
"KokkosP: Executing parallel-scan kernel on device %d with unique "
"execution identifier %llu\n",
devID, *kID);
devID, (unsigned long long)(*kID));

int level = kokkosp_print_region_stack();
kokkosp_print_region_stack_indent(level);

printf(" %s\n", name);
}

extern "C" void kokkosp_end_parallel_scan(const uint64_t kID) {
printf("KokkosP: Execution of kernel %llu is completed.\n", kID);
extern "C" void kokkospk_end_parallel_scan(const uint64_t kID) {
printf("KokkosP: Execution of kernel %llu is completed.\n",
(unsigned long long)(kID));
}

extern "C" void kokkosp_begin_parallel_reduce(const char* name,
Expand All @@ -111,7 +113,7 @@ extern "C" void kokkosp_begin_parallel_reduce(const char* name,
printf(
"KokkosP: Executing parallel-reduce kernel on device %d with unique "
"execution identifier %llu\n",
devID, *kID);
devID, (unsigned long long)(*kID));

int level = kokkosp_print_region_stack();
kokkosp_print_region_stack_indent(level);
Expand All @@ -120,7 +122,8 @@ extern "C" void kokkosp_begin_parallel_reduce(const char* name,
}

extern "C" void kokkosp_end_parallel_reduce(const uint64_t kID) {
printf("KokkosP: Execution of kernel %llu is completed.\n", kID);
printf("KokkosP: Execution of kernel %llu is completed.\n",
(unsigned long long)(kID));
}

extern "C" void kokkosp_begin_fence(const char* name, const uint32_t devID,
Expand All @@ -139,7 +142,7 @@ extern "C" void kokkosp_begin_fence(const char* name, const uint32_t devID,
printf(
"KokkosP: Executing fence on device %d with unique execution "
"identifier %llu\n",
devID, *kID);
devID, (unsigned long long)(*kID));

int level = kokkosp_print_region_stack();
kokkosp_print_region_stack_indent(level);
Expand All @@ -153,7 +156,8 @@ extern "C" void kokkosp_end_fence(const uint64_t kID) {
// dealing with the application's fence, which we filtered out in the callback
// for fences
if (kID != std::numeric_limits<uint64_t>::max()) {
printf("KokkosP: Execution of fence %llu is completed.\n", kID);
printf("KokkosP: Execution of fence %llu is completed.\n",
(unsigned long long)(kID));
}
}

Expand All @@ -173,14 +177,14 @@ extern "C" void kokkosp_pop_profile_region() {

extern "C" void kokkosp_allocate_data(SpaceHandle handle, const char* name,
void* ptr, uint64_t size) {
printf("KokkosP: Allocate<%s> name: %s pointer: %p size: %lu\n", handle.name,
name, ptr, size);
printf("KokkosP: Allocate<%s> name: %s pointer: %p size: %llu\n", handle.name,
name, ptr, (unsigned long long)(size));
}

extern "C" void kokkosp_deallocate_data(SpaceHandle handle, const char* name,
void* ptr, uint64_t size) {
printf("KokkosP: Deallocate<%s> name: %s pointer: %p size: %lu\n",
handle.name, name, ptr, size);
printf("KokkosP: Deallocate<%s> name: %s pointer: %p size: %llu\n",
handle.name, name, ptr, (unsigned long long)(size));
}

extern "C" void kokkosp_begin_deep_copy(SpaceHandle dst_handle,
Expand All @@ -191,7 +195,7 @@ extern "C" void kokkosp_begin_deep_copy(SpaceHandle dst_handle,
const void* src_ptr, uint64_t size) {
printf(
"KokkosP: DeepCopy<%s,%s> DST(name: %s pointer: %p) SRC(name: %s pointer "
"%p) Size: %lu\n",
"%p) Size: %llu\n",
dst_handle.name, src_handle.name, dst_name, dst_ptr, src_name, src_ptr,
size);
(unsigned long long)(size));
}
4 changes: 2 additions & 2 deletions profiling/chrome-tracing/kp_chrome_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ struct State {
gethostname(hostname, 256);

char *fileOutput = (char *)malloc(sizeof(char) * 256);
sprintf(fileOutput, "%s-%d-%s.json", hostname, (int)getpid(),
(NULL == mpi_rank) ? "0" : mpi_rank);
snprintf(fileOutput, 256, "%s-%d-%s.json", hostname, (int)getpid(),
(NULL == mpi_rank) ? "0" : mpi_rank);
#if defined(USE_MPI) && USE_MPI
MPI_Comm_rank(MPI_COMM_WORLD, &my_mpi_rank);
#else
Expand Down
19 changes: 9 additions & 10 deletions profiling/memory-events/kp_memory_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ double max_mem_usage() {
}

void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
const uint32_t devInfoCount,
Kokkos_Profiling_KokkosPDeviceInfo* deviceInfo) {
const uint32_t /*devInfoCount*/,
Kokkos_Profiling_KokkosPDeviceInfo* /*deviceInfo*/) {
num_spaces = 0;
for (int i = 0; i < 16; i++) space_size[i] = 0;

printf("KokkosP: MemoryEvents loaded (sequence: %d, version: %llu)\n",
loadSeq, interfaceVer);
loadSeq, (unsigned long long)(interfaceVer));

timer.reset();
}
Expand All @@ -69,7 +69,7 @@ void kokkosp_finalize_library() {

{
char* fileOutput = (char*)malloc(sizeof(char) * 256);
sprintf(fileOutput, "%s-%d.mem_events", hostname, pid);
snprintf(fileOutput, 256, "%s-%d.mem_events", hostname, pid);

FILE* ofile = fopen(fileOutput, "wb");
free(fileOutput);
Expand All @@ -78,14 +78,15 @@ void kokkosp_finalize_library() {
fprintf(ofile,
"# Time Ptr Size MemSpace Op "
" Name\n");
for (int i = 0; i < events.size(); i++) events[i].print_record(ofile);
for (unsigned int i = 0; i < events.size(); i++)
events[i].print_record(ofile);
fclose(ofile);
}

for (int s = 0; s < num_spaces; s++) {
char* fileOutput = (char*)malloc(sizeof(char) * 256);
sprintf(fileOutput, "%s-%d-%s.memspace_usage", hostname, pid,
space_name[s]);
snprintf(fileOutput, 256, "%s-%d-%s.memspace_usage", hostname, pid,
space_name[s]);

FILE* ofile = fopen(fileOutput, "wb");
free(fileOutput);
Expand All @@ -94,7 +95,7 @@ void kokkosp_finalize_library() {
fprintf(ofile,
"# Time(s) Size(MB) HighWater(MB) HighWater-Process(MB)\n");
uint64_t maxvalue = 0;
for (int i = 0; i < space_size_track[s].size(); i++) {
for (unsigned int i = 0; i < space_size_track[s].size(); i++) {
if (std::get<1>(space_size_track[s][i]) > maxvalue)
maxvalue = std::get<1>(space_size_track[s][i]);
fprintf(ofile, "%lf %.1lf %.1lf %.1lf\n",
Expand Down Expand Up @@ -126,7 +127,6 @@ void kokkosp_allocate_data(const SpaceHandle space, const char* label,
space_size_track[space_i].push_back(
std::make_tuple(time, space_size[space_i], max_mem_usage()));

int i = events.size();
events.push_back(
EventRecord(ptr, size, MEMOP_ALLOCATE, space_i, time, label));
}
Expand All @@ -151,7 +151,6 @@ void kokkosp_deallocate_data(const SpaceHandle space, const char* label,
std::make_tuple(time, space_size[space_i], max_mem_usage()));
}

int i = events.size();
events.push_back(
EventRecord(ptr, size, MEMOP_DEALLOCATE, space_i, time, label));
}
Expand Down
8 changes: 3 additions & 5 deletions profiling/memory-hwm/kp_hwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@
namespace KokkosTools {
namespace HighwaterMark {

static uint64_t uniqID = 0;

void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
const uint32_t devInfoCount,
Kokkos_Profiling_KokkosPDeviceInfo* deviceInfo) {
const uint32_t /*devInfoCount*/,
Kokkos_Profiling_KokkosPDeviceInfo* /*deviceInfo*/) {
printf(
"KokkosP: High Water Mark Library Initialized (sequence is %d, version: "
"%llu)\n",
loadSeq, interfaceVer);
loadSeq, (unsigned long long)(interfaceVer));
}

// darwin report rusage.ru_maxrss in bytes
Expand Down
17 changes: 9 additions & 8 deletions profiling/memory-usage/kp_memory_usage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ double max_mem_usage() {
return max_rssKB * 1024;
}

void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
const uint32_t devInfoCount,
Kokkos_Profiling_KokkosPDeviceInfo* deviceInfo) {
void kokkosp_init_library(const int /*loadSeq*/,
const uint64_t /*interfaceVer*/,
const uint32_t /*devInfoCount*/,
Kokkos_Profiling_KokkosPDeviceInfo* /*deviceInfo*/) {
num_spaces = 0;
for (int i = 0; i < 16; i++) space_size[i] = 0;

Expand All @@ -73,7 +74,7 @@ void kokkosp_finalize_library() {
fprintf(ofile,
"# Time(s) Size(MB) HighWater(MB) HighWater-Process(MB)\n");
uint64_t maxvalue = 0;
for (int i = 0; i < space_size_track[s].size(); i++) {
for (unsigned int i = 0; i < space_size_track[s].size(); i++) {
if (std::get<1>(space_size_track[s][i]) > maxvalue)
maxvalue = std::get<1>(space_size_track[s][i]);
fprintf(ofile, "%lf %.1lf %.1lf %.1lf\n",
Expand All @@ -87,8 +88,8 @@ void kokkosp_finalize_library() {
free(hostname);
}

void kokkosp_allocate_data(const SpaceHandle space, const char* label,
const void* const ptr, const uint64_t size) {
void kokkosp_allocate_data(const SpaceHandle space, const char* /*label*/,
const void* const /*ptr*/, const uint64_t size) {
std::lock_guard<std::mutex> lock(m);

double time = timer.seconds();
Expand All @@ -106,8 +107,8 @@ void kokkosp_allocate_data(const SpaceHandle space, const char* label,
std::make_tuple(time, space_size[space_i], max_mem_usage()));
}

void kokkosp_deallocate_data(const SpaceHandle space, const char* label,
const void* const ptr, const uint64_t size) {
void kokkosp_deallocate_data(const SpaceHandle space, const char* /*label*/,
const void* const /*ptr*/, const uint64_t size) {
std::lock_guard<std::mutex> lock(m);

double time = timer.seconds();
Expand Down
Loading

0 comments on commit 7ab2900

Please sign in to comment.