intel / mpi-benchmarks

145 stars 63 forks source link

Reordered bodies of `BENCHMARK` macros #20

Closed kawashima-fj closed 5 months ago

kawashima-fj commented 5 years ago

The bodies of the BENCHMARK macros in src_cpp/*/*_benchmark.cpp is wrongly ordered. For example, BENCHMARK(IMB_pingpong, PingPong) is expaneded as the following code. elem_PingPong is instantiated before name and descr are specialized.

template class OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>;
namespace { OriginalBenchmark<BenchmarkSuite<BS_MPI1>,IMB_pingpong> elem_PingPong; }
template<> const char *OriginalBenchmark<BenchmarkSuite<BS_MPI1>,IMB_pingpong>::name = "PingPong";
template<> smart_ptr<Bmark_descr> OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>::descr = __null;
template<> bool OriginalBenchmark<BenchmarkSuite<BS_MPI1>, IMB_pingpong>::init_description()

This causes the following compilation error with clang++.

MPI1/MPI1_benchmark.cpp:79:1: error: explicit specialization of 'name' after instantiation
BENCHMARK(IMB_pingpong, PingPong)
^
MPI1/MPI1_benchmark.cpp:73:107: note: expanded from macro 'BENCHMARK'
#define BENCHMARK(BMRK_FN, BMRK_NAME) template class OriginalBenchmark<BenchmarkSuite<BS_MPI1>, BMRK_FN>; \
                                                                                                          ^
./benchmark.h:88:114: note: expanded from macro '\
DECLARE_INHERITED_TEMPLATE'
#define DECLARE_INHERITED_TEMPLATE(CLASS, NAME) namespace { CLASS elem_ ## NAME; } template<> const char *CLASS::name = #NAME;
                                                                                                                 ^
helpers/original_benchmark.h:139:34: note: implicit instantiation first required here
            BMark->name = strdup(name);
                                 ^
JuliaRS commented 5 months ago

This changes have already unstreamed in product. Thank you for contribution :)