-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make babelstream runnable and test for different Accs #2299
Make babelstream runnable and test for different Accs #2299
Conversation
1965c6b
to
b38be37
Compare
6ffd219
to
0a5f6bd
Compare
{ | ||
dataTypeStr = "double-precision"; | ||
} | ||
std::cout << "Data type: " << typeid(DataType).name() << " " << dataTypeStr << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know, if there is some reporting function to add the information as key value pair to the output? At the moment, it simply captures the stdout and write a string to the xml, which make it hard to parse.
<?xml version="1.0" encoding="UTF-8"?>
<Catch2TestRun name="babelstream" rng-seed="1921823939" xml-format-version="2" catch2-version="3.3.2">
<TestCase name="Babelstream Bechmark by Alpaka Kernel - Single P. - TestAccs1D - 0" tags="[benchmark-test]" filename="/home/simeon/projects/alpaka/benchmarks/babelstream/src/benchmarkTest.cpp" line="418">
<BenchmarkResults name="CopyKernel" samples="100" resamples="100000" iterations="1" clockResolution="32.5898" estimatedDuration="1.62794e+07">
<!-- All values in nano seconds -->
<mean value="162549" lowerBound="162235" upperBound="163277" ci="0.95"/>
<standardDeviation value="2305.52" lowerBound="1253.62" upperBound="4617.02" ci="0.95"/>
<outliers variance="0.0750291" lowMild="0" lowSevere="0" highMild="1" highSevere="8"/>
</BenchmarkResults>
<BenchmarkResults name="AddKernel" samples="100" resamples="100000" iterations="1" clockResolution="32.5898" estimatedDuration="2.07714e+07">
<!-- All values in nano seconds -->
<mean value="208480" lowerBound="207810" upperBound="209855" ci="0.95"/>
<standardDeviation value="4688.39" lowerBound="2825.43" upperBound="8760.11" ci="0.95"/>
<outliers variance="0.161071" lowMild="0" lowSevere="0" highMild="1" highSevere="6"/>
</BenchmarkResults>
<BenchmarkResults name="MulKernel" samples="100" resamples="100000" iterations="1" clockResolution="32.5898" estimatedDuration="1.19507e+07">
<!-- All values in nano seconds -->
<mean value="122044" lowerBound="121594" upperBound="122670" ci="0.95"/>
<standardDeviation value="2676.42" lowerBound="2061.12" upperBound="3957.46" ci="0.95"/>
<outliers variance="0.151683" lowMild="0" lowSevere="0" highMild="1" highSevere="1"/>
</BenchmarkResults>
<BenchmarkResults name="TriadKernel" samples="100" resamples="100000" iterations="1" clockResolution="32.5898" estimatedDuration="2.11882e+07">
<!-- All values in nano seconds -->
<mean value="212046" lowerBound="211493" upperBound="212948" ci="0.95"/>
<standardDeviation value="3544.51" lowerBound="2546.6" upperBound="5707.04" ci="0.95"/>
<outliers variance="0.094408" lowMild="0" lowSevere="0" highMild="1" highSevere="9"/>
</BenchmarkResults>
<OverallResult success="true" skips="0">
<StdOut>
========================
Time:2024-07-01 14:21:45
Using alpaka accelerator: AccCpuSerial<1,unsigned int>
Data type: f single-precision
Data size: 1048576 elements
Work division: {gridBlockExtent: (1048576), blockThreadExtent: (1), threadElemExtent: (1)}
</StdOut>
</OverallResult>
</TestCase>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I will use "INFO" macro of catch2. Good idea thanks. It turned out to be -r json
also works for catch2 3.5.2
. I am doing it for json, more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json reporter seem to not include benchmark results only records REQUIRE results etc. XML reporter prints benchmark results as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only WARN
has worked to log output other than using cout
. I will use WARN
. Because others only workd when there is REQUIRE/CHECK and it fails.
TEST_CASE("TESTCASE tesing trial", "[testcase-test]")
{
std::string dataType = "floating-point";
std::string dataSize = std::to_string(100000);
int arraySize=1234;
WARN(dataType); // This will be included as custom XML in the report
INFO("\n normal info Data type is" << dataType);
UNSCOPED_INFO("unscoped Data type is" << dataType);
INFO("info example");
UNSCOPED_INFO("unscoped example");
INFO("normal info array size is" << arraySize);
UNSCOPED_INFO("unscoped array size is" << arraySize);
INFO("normal info data size is" << dataSize);
UNSCOPED_INFO("unscoped data size is" << dataSize);
CAPTURE(dataSize);
CAPTURE(dataType);
// !!!!
CHECK(arraySize!=1234); // If this fails all INFO, capture and UNSCOPED_INFO prints. Otherwise only WARN prints
SUCCEED("SUCCEED");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need additional operation to extract data from fields. May be I should use cout output directly and convert it to json by a script instead of dealing with this...
<Warning filename="/home/yusufo81/projects/alpaka-dir/alpaka/benchmarks/babelstream/src/benchmarkTest.cpp" line="146">
TimeStamp:2024-07-09 15:06:59
</Warning>
<Warning filename="/home/yusufo81/projects/alpaka-dir/alpaka/benchmarks/babelstream/src/benchmarkTest.cpp" line="147">
DataSize:1048576
</Warning>
<Warning filename="/home/yusufo81/projects/alpaka-dir/alpaka/benchmarks/babelstream/src/benchmarkTest.cpp" line="148">
DataSize:single-precision
</Warning>
} | ||
} | ||
|
||
std::string getCurrentTimestamp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the forward declaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a warning at one compiler "warning: no previous declaration for ‘std::string getCurrentTimestamp()’ [-Wmissing-declarations]
" therefore i added a declaration. Alternatively, I can make the function static
as well. Somehow one of the compilers forced for declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the function static. Like functions in some other tests: e.g. alpaka/test/unit/mem/buf/src/BufTest.cpp
897c296
to
97286cc
Compare
@mehmetyusufoglu The CMake file for the benchmark is missing to include catch in case you compile without |
6f755f1
to
846856a
Compare
~~The output on the terminal should looks like the old output. ~~ Sry my fold, the output is nearly equal, only MB is now GB/s |
I updated my cmment above.
Is this different compared too the original code?
|
No, same as original. It was not stated in the output. Therefore i did not mention. i will not state in the output as well so not change the code. |
|
846856a
to
d088742
Compare
It is the same with the previous code's output. Besides there are 4 additional fields as info: 1. Acc type, 2. data item size, 3. workdiv and 4. correct data-throughput for each kernel. |
All tests pass at gitlab and github. No problem. |
@mehmetyusufoglu please amend and force push this PR again, the CI is fixed |
The problem still exists. As I wrote if you only enable benchmarking catch will not found if you not provide an installed catch version externally.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2299 (comment) must be fixed before we can merge this PR.
This error will not show up in the CI because we enable tests and benchmarking in the CI always together.
@SimeonEhrig my latest commit would not solve the issue i think. What is your opinion? |
8fde9e5
to
93fccb0
Compare
Something get broken. If I run CMake Error at thirdParty/CMakeLists.txt:42 (find_package):
Could not find a package configuration file provided by "Catch2" (requested
version 3.5.2) with any of the following names:
Catch2Config.cmake
catch2-config.cmake
Add the installation prefix of "Catch2" to CMAKE_PREFIX_PATH or set
"Catch2_DIR" to a directory containing one of the above files. If "Catch2"
provides a separate development package or SDK, be sure it has been
installed.
This CMake path should be used, if the CMake variable |
CMakeLists.txt
Outdated
cmake_dependent_option(alpaka_USE_INTERNAL_CATCH2 "Use internally shipped Catch2" ON BUILD_TESTING OFF) | ||
cmake_dependent_option(alpaka_USE_INTERNAL_CATCH2 "Use internally shipped Catch2" ON alpaka_BUILD_BENCHMARKS OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you must merge this line and the line above see https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html
If you add two lines the last line will have the highest priority.
CMakeLists.txt
Outdated
@@ -48,7 +48,9 @@ option(alpaka_INSTALL_TEST_HEADER "Install headers of the namespace alpaka::test | |||
|
|||
include(CMakeDependentOption) | |||
cmake_dependent_option(alpaka_CHECK_HEADERS "Check all alpaka headers as part of the tests whether they can be compiled standalone." OFF BUILD_TESTING OFF) | |||
cmake_dependent_option(alpaka_CHECK_HEADERS "Check all alpaka headers as part of the benchmarks whether they can be compiled standalone." OFF alpaka_BUILD_BENCHMARKS OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you must merge this line and the line above see https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html
If you add two lines the last line will have the highest priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I have added an additional local variable as
(alpaka_BUILD_BENCHMARKS OR BUILD_TESTING)
.
But; Benchmarks were locally not compilable and i got the error,
/home/yusufo81/projects/alpaka-dir/alpaka/benchmarks/babelstream/src/babelStreamMainTest.cpp:5:10: fatal error: alpaka/alpaka.hpp: No such file or directory 5 | #include <alpaka/alpaka.hpp> | ^~~~~~~~~~~~~~~~~~~
- to solve this i had to change the condition to call
add_subdirectory("test/")
at line 167. But with this change, setting benchmark cmake variable became the same thing of settingBUILD_TESTING
. It is a kind of work-around.
\# Only build the tests if alpaka is the top-level project and BUILD_TESTING or alpaka_BUILD_BENCHMARKS is ON \# Note: alpaka_BUILD_BENCHMARKS is added with an OR besides BUILD_TESTING below. \# Because the benchmark which uses catch2 is not compilable locally without adding test directory as below \# or without setting BUILD_TESTING cmake variable to ON. See PR2299.
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND (BUILD_TESTING OR alpaka_BUILD_BENCHMARKS))
add_subdirectory("test/")
endif()
CMakeLists.txt
Outdated
# Note: alpaka_BUILD_BENCHMARKS is added with an OR besides BUILD_TESTING below. | ||
# Because the benchmark which uses catch2 is not compilable locally without adding test directory as below | ||
# or without setting BUILD_TESTING cmake variable to ON. See PR2299. | ||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND (BUILD_TESTING OR alpaka_BUILD_BENCHMARKS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not want to build testing if benchmark only is enabled.
I will provide a fix after lunch! |
57a3e98
to
3057e10
Compare
Co-authored-by: René Widera <[email protected]> Co-authored-by: Simeon Ehrig <[email protected]>
3057e10
to
1840791
Compare
babelstream benchmarking was creating errors and had unnecessary parts (because it was developed as an extention of the test at Bristol Uni. )
./babelstream --array-size=1280000 --number-runs=10
./babelstream --success
./babelstream -r a.xml
./babelstream --success --array-size=1280000 --number-runs=10
./babelstream --help
(or -h or -?)Babelstream has 5 simple kernels for vector operations. Add, Mul, Copy, Triad and Dot product. And there is an Init kernel.
RunTimes are measured by using std::chrono
RESULTS for
./babelstream --array-size=33554432 --number-runs=100
are below. They are equal ( or slightly better) compared to previous implementation which runs 100 times and uses minimum time as well.Full output file:
babelStreamOut.txt
Old implementation values for 4 kernels 100 runs in the following image: