Skip to content

Commit

Permalink
Flush output streams before creating a process to drop caches (#10762)
Browse files Browse the repository at this point in the history
Small improvement for the `try_drop_l3_cache` feature in cuIO benchmarks. 
Prevents unflushed output from the original process from intermingling with the output from the `popen` process.

Authors:
  - Vukasin Milovanovic (https://github.com/vuule)

Approvers:
  - https://github.com/nvdbaranec
  - Bradley Dice (https://github.com/bdice)

URL: #10762
  • Loading branch information
vuule authored Apr 29, 2022
1 parent 9112907 commit bf10a94
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpp/benchmarks/io/cuio_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <benchmarks/io/cuio_common.hpp>

#include <cstdio>
#include <fstream>
#include <numeric>
#include <string>
Expand Down Expand Up @@ -145,6 +146,8 @@ std::vector<cudf::size_type> segments_in_chunk(int num_segments, int num_chunks,
// Executes the command and returns stderr output
std::string exec_cmd(std::string_view cmd)
{
// Prevent the output from the command from mixing with the original process' output
std::fflush(nullptr);
// Switch stderr and stdout to only capture stderr
auto const redirected_cmd = std::string{"( "}.append(cmd).append(" 3>&2 2>&1 1>&3) 2>/dev/null");
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(redirected_cmd.c_str(), "r"), pclose);
Expand Down

0 comments on commit bf10a94

Please sign in to comment.