Hi Matthias,<br><br>Thanks for doing this! However I think we also need to update test-suite.py for this change, because I think --only-test handling will now be broken for SingleSource tests. <br><br>James<br><div class="gmail_quote"><div dir="ltr">On Sat, 26 Mar 2016 at 04:11, Matthias Braun via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: matze<br>
Date: Fri Mar 25 23:05:50 2016<br>
New Revision: 264499<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264499&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264499&view=rev</a><br>
Log:<br>
cmake/lit: Put SingleSource executables into separate directories<br>
<br>
This fixes the problem of compiletimes not getting collected corrected.<br>
<br>
Modified:<br>
test-suite/trunk/cmake/modules/SingleMultiSource.cmake<br>
test-suite/trunk/litsupport/compiletime.py<br>
<br>
Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=264499&r1=264498&r2=264499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=264499&r1=264498&r2=264499&view=diff</a><br>
==============================================================================<br>
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)<br>
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Fri Mar 25 23:05:50 2016<br>
@@ -136,33 +136,35 @@ macro(test_suite_add_executable name mai<br>
list(FIND PROGRAMS_TO_SKIP ${name} name_idx)<br>
# Should we skip this?<br>
if(${name_idx} EQUAL -1)<br>
- get_unique_exe_name(source_exename ${mainsource})<br>
- add_executable(${source_exename} ${ARGN})<br>
- append_compile_flags(${source_exename} ${CFLAGS})<br>
- append_compile_flags(${source_exename} ${CPPFLAGS})<br>
- append_compile_flags(${source_exename} ${CXXFLAGS})<br>
+ get_unique_exe_name(executable ${mainsource})<br>
+ add_executable(${executable} ${ARGN})<br>
+ append_compile_flags(${executable} ${CFLAGS})<br>
+ append_compile_flags(${executable} ${CPPFLAGS})<br>
+ append_compile_flags(${executable} ${CXXFLAGS})<br>
# Note that we cannot use target_link_libraries() here because that one<br>
# only interprets inputs starting with '-' as flags.<br>
- append_link_flags(${source_exename} ${LDFLAGS})<br>
+ append_link_flags(${executable} ${LDFLAGS})<br>
+ set(executable_path ${CMAKE_CURRENT_BINARY_DIR})<br>
+ if(CMAKE_RUNTIME_OUTPUT_DIRECTORY)<br>
+ set(executable_path ${executable_path}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY})<br>
+ endif()<br>
+ set(executable_path ${executable_path}/${executable})<br>
if (TEST_SUITE_PROFILE_USE)<br>
- append_compile_flags(${source_exename} -fprofile-instr-use=${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.profdata)<br>
- append_link_flags(${source_exename} -fprofile-instr-use=${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.profdata)<br>
+ append_compile_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)<br>
+ append_link_flags(${executable} -fprofile-instr-use=${executable_path}.profdata)<br>
endif()<br>
<br>
# Fall back to old style involving RUN_OPTIONS and STDIN_FILENAME if<br>
# llvm_test_run() was not called yet.<br>
if(NOT TESTSCRIPT)<br>
- llvm_test_traditional(${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.test<br>
- ${CMAKE_CURRENT_BINARY_DIR}/${source_exename}<br>
- ${name})<br>
+ llvm_test_traditional(${executable_path}.test ${executable_path} ${name})<br>
else()<br>
- llvm_add_test(${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.test<br>
- ${CMAKE_CURRENT_BINARY_DIR}/${source_exename})<br>
+ llvm_add_test(${executable_path}.test ${executable_path})<br>
endif()<br>
if (NOT TEST_SUITE_USE_PERF)<br>
- add_dependencies(${source_exename} timeit-target)<br>
+ add_dependencies(${executable} timeit-target)<br>
endif()<br>
- add_dependencies(${source_exename} timeit-host fpcmp-host)<br>
+ add_dependencies(${executable} timeit-host fpcmp-host)<br>
endif()<br>
endmacro()<br>
<br>
@@ -175,8 +177,14 @@ macro(llvm_singlesource)<br>
string(REGEX REPLACE ".[cp]+$" "" path ${source})<br>
string(REGEX REPLACE ".*/" "" name ${path})<br>
<br>
+ # Setting CMAKE_RUNTIME_OUTPUT_DIRECTORY lets cmake put the files into a<br>
+ # different subdirectory for each benchmark. This is usefull for<br>
+ # differentiating which statistics like *.o.time files belongs to which<br>
+ # benchmark.<br>
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${name})<br>
test_suite_add_executable(${name} ${source} ${source})<br>
endforeach()<br>
+ unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY)<br>
endmacro()<br>
<br>
# Configure the current directory as a MultiSource subdirectory - i.e. there is<br>
<br>
Modified: test-suite/trunk/litsupport/compiletime.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/compiletime.py?rev=264499&r1=264498&r2=264499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/compiletime.py?rev=264499&r1=264498&r2=264499&view=diff</a><br>
==============================================================================<br>
--- test-suite/trunk/litsupport/compiletime.py (original)<br>
+++ test-suite/trunk/litsupport/compiletime.py Fri Mar 25 23:05:50 2016<br>
@@ -4,19 +4,26 @@ import timeit<br>
<br>
<br>
def _getCompileTime(context):<br>
+ basepath = os.path.dirname(context.test.getFilePath())<br>
+ dirs = [basepath]<br>
+ # Single source .o/.o.time files are placed in a different directory.<br>
+ name = os.path.basename(basepath)<br>
+ alternate_dir = "%s/../CMakeFiles/%s.dir" % (basepath, name)<br>
+ dirs.append(alternate_dir)<br>
+<br>
# TODO: This is not correct yet as the directory may contain .o.time files<br>
# of multiple benchmarks in the case of SingleSource tests.<br>
compile_time = 0.0<br>
link_time = 0.0<br>
- basepath = os.path.dirname(context.test.getFilePath())<br>
- for path, subdirs, files in os.walk(basepath):<br>
- for file in files:<br>
- if file.endswith('.o.time'):<br>
- fullpath = os.path.join(path, file)<br>
- compile_time += timeit.getUserTime(fullpath)<br>
- if file.endswith('.link.time'):<br>
- fullpath = os.path.join(path, file)<br>
- link_time += timeit.getUserTime(fullpath)<br>
+ for dir in dirs:<br>
+ for path, subdirs, files in os.walk(dir):<br>
+ for file in files:<br>
+ if file.endswith('.o.time'):<br>
+ fullpath = os.path.join(path, file)<br>
+ compile_time += timeit.getUserTime(fullpath)<br>
+ if file.endswith('.link.time'):<br>
+ fullpath = os.path.join(path, file)<br>
+ link_time += timeit.getUserTime(fullpath)<br>
return {<br>
'compile_time': lit.Test.toMetricValue(compile_time),<br>
'link_time': lit.Test.toMetricValue(link_time),<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>