Skip to content

Commit

Permalink
cmake: options to silence stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
cthbleachbit committed May 6, 2022
1 parent f5acbe7 commit a06c015
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ else()
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
endif ()

# silence mode
option(GAPPP_SILENT "Do not print anything - for benchmark only?" OFF)
if (GAPPP_SILENT)
add_compile_definitions(GAPPP_SILENT)
endif()

# GPU direct
option(GAPPP_GPU_DIRECT "Build with GPU direct support" ON)
if (GAPPP_GPU_DIRECT)
Expand Down
1 change: 0 additions & 1 deletion cuda-src/l3fwd.cu
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ namespace GAPPP {
struct rte_ipv4_hdr *ip_hdr;
ip_hdr = rte_pktmbuf_mtod_offset(packets[i], struct rte_ipv4_hdr *, sizeof(rte_ether_hdr));
unsigned int ip_dst = ip_hdr->dst_addr;
printf("Post IP addr\n");
cudaMemcpy((void *) (gpu_dst_ips + i), &ip_dst, sizeof(unsigned int), cudaMemcpyHostToDevice);
}
cudaDeviceSynchronize();
Expand Down
2 changes: 2 additions & 0 deletions include/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ namespace GAPPP {
};

inline void whine(Severity sev, const std::string &message, const std::string &component = "???") {
#ifndef GAPPP_SILENT
std::string print_out = fmt::format("[{}/{}] {}\n", component, sev_to_string(sev), message);
std::cout << print_out << std::flush;
#endif
if (unlikely(sev == Severity::CRIT)) {
throw std::runtime_error(print_out);
}
Expand Down
1 change: 1 addition & 0 deletions src/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ namespace GAPPP {
rte_pktmbuf_free(packets[i]);
}
whine(Severity::WARN, fmt::format("No TX buffer allocated for {}", id), GAPPP_LOG_ROUTER);
return 0;
};
unsigned int ret = rte_ring_enqueue_burst(tx_ring, reinterpret_cast<void *const *>(packets), len, nullptr);
if (ret < len) {
Expand Down

0 comments on commit a06c015

Please sign in to comment.