Skip to content

Commit fb4bd68

Browse files
committed
Merge branch 'master' into comparable-enums
2 parents 1f0cbac + f1ef08a commit fb4bd68

File tree

887 files changed

+30397
-12004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

887 files changed

+30397
-12004
lines changed

CMakeLists.txt

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ if(POLICY CMP0068)
77
cmake_policy(SET CMP0068 OLD)
88
endif()
99

10+
# Honour CMAKE_CXX_STANDARD in try_compile(), needed for check_cxx_native_regex.
11+
if(POLICY CMP0067)
12+
cmake_policy(SET CMP0067 NEW)
13+
endif()
14+
1015
# Add path for custom CMake modules.
1116
list(APPEND CMAKE_MODULE_PATH
1217
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -385,63 +390,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING
385390
# End of user-configurable options.
386391
#
387392

388-
# Look for either a program in execute_process()'s path or for a hardcoded path.
389-
# Find a program's version and set it in the parent scope.
390-
# Replace newlines with spaces so it prints on one line.
391-
function(find_version cmd flag find_in_path)
392-
if(find_in_path)
393-
message(STATUS "Finding installed version for: ${cmd}")
394-
else()
395-
message(STATUS "Finding version for: ${cmd}")
396-
endif()
397-
execute_process(
398-
COMMAND ${cmd} ${flag}
399-
OUTPUT_VARIABLE out
400-
OUTPUT_STRIP_TRAILING_WHITESPACE)
401-
if(NOT out)
402-
if(find_in_path)
403-
message(STATUS "tried to find version for ${cmd}, but ${cmd} not found in path, continuing")
404-
else()
405-
message(FATAL_ERROR "tried to find version for ${cmd}, but ${cmd} not found")
406-
endif()
407-
else()
408-
string(REPLACE "\n" " " out2 ${out})
409-
message(STATUS "Found version: ${out2}")
410-
endif()
411-
message(STATUS "")
412-
endfunction()
413-
414-
# Print out path and version of any installed commands.
415-
# We migth be using the wrong version of a command, so record them all.
416-
function(print_versions)
417-
find_version("${CMAKE_COMMAND}" "--version" TRUE)
418-
419-
message(STATUS "Finding version for: ${CMAKE_COMMAND}")
420-
message(STATUS "Found version: ${CMAKE_VERSION}")
421-
message(STATUS "")
422-
423-
get_filename_component(CMAKE_MAKE_PROGRAM_BN "${CMAKE_MAKE_PROGRAM}" NAME_WE)
424-
if(${CMAKE_MAKE_PROGRAM_BN} STREQUAL "ninja" OR
425-
${CMAKE_MAKE_PROGRAM_BN} STREQUAL "make")
426-
find_version(${CMAKE_MAKE_PROGRAM_BN} "--version" TRUE)
427-
find_version(${CMAKE_MAKE_PROGRAM} "--version" FALSE)
428-
endif()
429-
430-
if(${SWIFT_PATH_TO_CMARK_BUILD})
431-
find_version("cmark" "--version" TRUE)
432-
find_version("${SWIFT_PATH_TO_CMARK_BUILD}/src/cmark" "--version" FALSE)
433-
endif()
434-
435-
message(STATUS "Finding version for: ${CMAKE_C_COMPILER}")
436-
message(STATUS "Found version: ${CMAKE_C_COMPILER_VERSION}")
437-
message(STATUS "")
438-
439-
message(STATUS "Finding version for: ${CMAKE_CXX_COMPILER}")
440-
message(STATUS "Found version: ${CMAKE_CXX_COMPILER_VERSION}")
441-
message(STATUS "")
442-
endfunction()
443-
444-
445393
set(SWIFT_BUILT_STANDALONE FALSE)
446394
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
447395
set(SWIFT_BUILT_STANDALONE TRUE)
@@ -493,7 +441,21 @@ include(CheckCXXSourceRuns)
493441
include(CMakeParseArguments)
494442
include(CMakePushCheckState)
495443

496-
print_versions()
444+
# Print out path and version of any installed commands
445+
message(STATUS "CMake (${CMAKE_COMMAND}) Version: ${CMAKE_VERSION}")
446+
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
447+
OUTPUT_VARIABLE _CMAKE_MAKE_PROGRAM_VERSION
448+
OUTPUT_STRIP_TRAILING_WHITESPACE)
449+
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")
450+
message(STATUS "C Compiler (${CMAKE_C_COMPILER}) Version: ${CMAKE_C_COMPILER_VERSION}")
451+
message(STATUS "C++ Compiler (${CMAKE_CXX_COMPILER}) Version: ${CMAKE_CXX_COMPILER_VERSION}")
452+
if(SWIFT_PATH_TO_CMARK_BUILD)
453+
execute_process(COMMAND ${SWIFT_PATH_TO_CMARK_BUILD}/src/cmark --version
454+
OUTPUT_VARIABLE _CMARK_VERSION
455+
OUTPUT_STRIP_TRAILING_WHITESPACE)
456+
message(STATUS "CMark Version: ${_CMARK_VERSION}")
457+
endif()
458+
message(STATUS "")
497459

498460
include(SwiftSharedCMakeConfig)
499461

@@ -872,6 +834,9 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
872834
message(STATUS "Building Swift runtime with:")
873835
message(STATUS " Leak Detection Checker Entrypoints: ${SWIFT_RUNTIME_ENABLE_LEAK_CHECKER}")
874836
message(STATUS "")
837+
838+
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
839+
message(STATUS "")
875840
else()
876841
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
877842
message(STATUS "")
@@ -930,6 +895,19 @@ else()
930895
find_package(LibEdit)
931896
endif()
932897

898+
if(LibEdit_FOUND)
899+
cmake_push_check_state()
900+
list(APPEND CMAKE_REQUIRED_INCLUDES ${LibEdit_INCLUDE_DIRS})
901+
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LibEdit_LIBRARIES})
902+
check_symbol_exists(el_wgets "histedit.h" HAVE_EL_WGETS)
903+
if(HAVE_EL_WGETS)
904+
set(LibEdit_HAS_UNICODE YES)
905+
else()
906+
set(LibEdit_HAS_UNICODE NO)
907+
endif()
908+
cmake_pop_check_state()
909+
endif()
910+
933911
check_symbol_exists(wait4 "sys/wait.h" HAVE_WAIT4)
934912

935913
check_symbol_exists(proc_pid_rusage "libproc.h" HAVE_PROC_PID_RUSAGE)

benchmark/scripts/Benchmark_DTrace.in

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ class DTraceResult(perf_test_driver.Result):
3535
self, name, status, output, XFAIL_LIST)
3636
self.csv_output = csv_output
3737

38+
def is_failure(self):
39+
return not bool(self.status)
40+
3841
@classmethod
3942
def data_headers(cls):
4043
return [
41-
'Name', 'Result', 'strong_retain', 'strong_retain/iter',
42-
'strong_release', 'strong_release/iter']
44+
'Name', 'Result', 'Total RR Opts', 'Total RR Opts/Iter']
4345

4446
@classmethod
4547
def data_format(cls, max_test_len):
@@ -70,7 +72,7 @@ class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
7072
def __init__(self, binary, xfail_list, csv_output):
7173
perf_test_driver.BenchmarkDriver.__init__(
7274
self, binary, xfail_list,
73-
enable_parallel=False,
75+
enable_parallel=True,
7476
opt_levels=['O'])
7577
self.csv_output = csv_output
7678

@@ -86,24 +88,46 @@ class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
8688
sys.stdout.flush()
8789

8890
def get_results_with_iters(iters):
91+
e = os.environ
92+
e['SWIFT_DETERMINISTIC_HASHING'] = '1'
8993
p = subprocess.Popen([
9094
'sudo', 'dtrace', '-s', DTRACE_PATH,
91-
'-c', '%s %s %s' % (data['path'], data['test_name'],
92-
'--num-iters=%d' % iters)
93-
], stdout=subprocess.PIPE, stderr=open('/dev/null', 'w'))
95+
'-c', '%s %s %s %s' % (data['path'], data['test_name'],
96+
'--num-iters=%d' % iters,
97+
'--num-samples=2')
98+
], stdout=subprocess.PIPE, stderr=open('/dev/null', 'w'), env=e)
9499
results = [x for x in p.communicate()[0].split("\n") if len(x) > 0]
95100
return [
96101
x.split(',')[1] for x in
97102
results[results.index('DTRACE RESULTS') + 1:]]
98103
iter_2_results = get_results_with_iters(2)
99104
iter_3_results = get_results_with_iters(3)
105+
iter_5_results = get_results_with_iters(5)
100106

101107
results = []
102-
for x in zip(iter_2_results, iter_3_results):
103-
results.append(x[1])
104-
results.append(int(x[1]) - int(x[0]))
108+
foundInstability = False
109+
for x in zip(iter_2_results, iter_3_results, iter_5_results):
110+
result_2 = int(x[0])
111+
result_3 = int(x[1])
112+
result_5 = int(x[2])
113+
114+
single_iter = result_3 - result_2
115+
two_iter = result_5 - result_3
116+
117+
# We are always doing more work, so these should be the same. Fail
118+
# if we have a negative number.
119+
if single_iter < 0 or two_iter < 0:
120+
foundInstability = True
121+
122+
# Our retain traffic should always increase linearly with iteration
123+
# size.
124+
if (single_iter * 2) == two_iter:
125+
foundInstability = True
126+
127+
results.append(result_3)
128+
results.append(single_iter)
105129

106-
return DTraceResult(test_name, 0, results, self.csv_output)
130+
return DTraceResult(test_name, int(not foundInstability), results)
107131

108132

109133
SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -117,7 +141,7 @@ def parse_args():
117141
default=None,
118142
help='Filter out any test that does not match the given regex')
119143
parser.add_argument(
120-
'-csv',
144+
'--emit-csv',
121145
default=False,
122146
action='store_true',
123147
help="Emit csv output",

benchmark/scripts/perf_test_driver/perf_test_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import subprocess
2222

2323

24-
BENCHMARK_OUTPUT_RE = re.compile('([^,]+),')
24+
BENCHMARK_OUTPUT_RE = re.compile(r'\d+,([^,]+)')
2525

2626

2727
class Result(object):

benchmark/scripts/perf_test_driver/swift_stats.d

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@
1212

1313
pid$target:*:swift_retain:entry
1414
{
15-
@counts[probefunc] = count();
15+
@counts["rr-opts"] = count();
1616
}
1717

1818
pid$target:*:swift_release:entry
1919
{
20-
@counts[probefunc] = count();
20+
@counts["rr-opts"] = count();
21+
}
22+
23+
pid$target:*:swift_retain_n:entry
24+
{
25+
@counts["rr-opts"] = count();
26+
}
27+
28+
pid$target:*:swift_release_n:entry
29+
{
30+
@counts["rr-opts"] = count();
2131
}
2232

2333
END

0 commit comments

Comments
 (0)