Skip to content

Commit

Permalink
#2302: Fix warnings and install perf in CI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 25, 2024
1 parent 43abf5a commit b4280af
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 57 deletions.
1 change: 1 addition & 0 deletions ci/docker/ubuntu-gnu-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apt-get update -y -q && \
g++-$(echo ${compiler} | cut -d- -f2) \
${zoltan_enabled:+gfortran-$(echo ${compiler} | cut -d- -f2)} \
ca-certificates \
linux-tools \
ccache \
curl \
git \
Expand Down
29 changes: 3 additions & 26 deletions examples/collection/do_flops_papi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,6 @@ static constexpr std::size_t const default_num_objs = 1;
static constexpr double const default_tol = 1.0e-02;
static constexpr std::size_t const default_flops_per_iter = 100000;

volatile double a = 0.5, b = 2.2;

void
dummy( void *array )
{
/* Confuse the compiler so as not to optimize
away the flops in the calling routine */
/* Cast the array as a void to eliminate unused argument warning */
( void ) array;
}

void
do_flops( int n )
{
int i;
double c = 0.11;

for ( i = 0; i < n; i++ ) {
c += a * b;
}
dummy( ( void * ) &c );
}

double pi(uint64_t n) {
double sum = 0.0;
Expand Down Expand Up @@ -178,7 +156,7 @@ struct GenericWork : vt::Collection<GenericWork, vt::Index1D> {

VecMsg() = default;

VecMsg(vt::IdxBase const& in_index) :
explicit VecMsg(vt::IdxBase const& in_index) :
vt::CollectionMessage<GenericWork>(),
from_index(in_index)
{ }
Expand Down Expand Up @@ -210,16 +188,15 @@ struct GenericWork : vt::Collection<GenericWork, vt::Index1D> {
vt::IdxBase const myIdx = getIndex().x();
auto proxy = this->getCollectionProxy();


if (myIdx > 0) {
proxy[myIdx - 1].send<VecMsg, &GenericWork::exchange>(
myIdx
VecMsg(myIdx)
);
}

if (size_t(myIdx) < numObjs_ - 1) {
proxy[myIdx + 1].send<VecMsg, &GenericWork::exchange>(
myIdx
VecMsg(myIdx)
);
}
}
Expand Down
30 changes: 3 additions & 27 deletions examples/collection/do_flops_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,6 @@ static constexpr std::size_t const default_num_objs = 100;
static constexpr double const default_tol = 1.0e-02;
static constexpr std::size_t const default_flops_per_iter = 100000;

volatile double a = 0.5, b = 2.2;

void
dummy( void *array )
{
/* Confuse the compiler so as not to optimize
away the flops in the calling routine */
/* Cast the array as a void to eliminate unused argument warning */
( void ) array;
}

void
do_flops( int n )
{
int i;
double c = 0.11;

for ( i = 0; i < n; i++ ) {
c += a * b;
}
dummy( ( void * ) &c );
}

double pi(uint64_t n) {
double sum = 0.0;
int sign = 1;
Expand Down Expand Up @@ -179,7 +156,7 @@ struct GenericWork : vt::Collection<GenericWork, vt::Index1D> {

VecMsg() = default;

VecMsg(vt::IdxBase const& in_index) :
explicit VecMsg(vt::IdxBase const& in_index) :
vt::CollectionMessage<GenericWork>(),
from_index(in_index)
{ }
Expand Down Expand Up @@ -211,16 +188,15 @@ struct GenericWork : vt::Collection<GenericWork, vt::Index1D> {
vt::IdxBase const myIdx = getIndex().x();
auto proxy = this->getCollectionProxy();


if (myIdx > 0) {
proxy[myIdx - 1].send<VecMsg, &GenericWork::exchange>(
myIdx
VecMsg(myIdx)
);
}

if (size_t(myIdx) < numObjs_ - 1) {
proxy[myIdx + 1].send<VecMsg, &GenericWork::exchange>(
myIdx
VecMsg(myIdx)
);
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/vt/metrics/perf_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,20 @@ std::unordered_map<std::string, uint64_t> PerfData::getTaskMeasurements()
std::unordered_map<std::string, uint64_t> measurements;
for (size_t i = 0; i < event_fds_.size(); ++i)
{
uint64_t count;
if (event_fds_[i] != -1 && read(event_fds_[i], &count, sizeof(uint64_t)) != -1) {
measurements[event_names_[i]] = count;
uint64_t count = 0;
if (event_fds_[i] != -1) {
ssize_t bytesRead = read(event_fds_[i], &count, sizeof(uint64_t));
if (bytesRead == sizeof(uint64_t)) {
measurements[event_names_[i]] = count;
} else if (bytesRead == -1) {
vtAbort("Failed to read perf event data for: " + event_names_[i] + ". Error: " + std::strerror(errno));
} else {
vtAbort("Incomplete read for: " + event_names_[i] + ". Expected " + std::to_string(sizeof(uint64_t)) +
" bytes, but got " + std::to_string(bytesRead));
}
}
else {
vtWarn("Failed to read perf event data for: " + event_names_[i]);
vtAbort("Invalid file descriptor for: " + event_names_[i]);
}
}
return measurements;
Expand Down

0 comments on commit b4280af

Please sign in to comment.