Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BasedOnStyle: LLVM

BreakTemplateDeclarations: Yes
ColumnLimit: 100
FixNamespaceComments: false
IndentWidth: 4
NamespaceIndentation: All
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ source_group(Sources FILES ${sources})
add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers})
target_link_libraries(${CMAKE_PROJECT_NAME} stream_compaction)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})

add_executable(measure_time src/measure_time.cpp ${headers})
target_link_libraries(measure_time stream_compaction)
473 changes: 465 additions & 8 deletions README.md

Large diffs are not rendered by default.

Binary file added img/efficient-plus-add-sums-ncu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/efficient-plus-nsys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/efficient-plus-scan-per-block-ncu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/performance-gpu-only.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/thrust-ncu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/thrust-nsys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
32 changes: 32 additions & 0 deletions scripts/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import subprocess
from pathlib import Path
from typing import Literal

ROOT_DIR = Path(__file__).parent.parent.absolute()
MEASURE_TIME_EXE = ROOT_DIR / "build" / "bin" / "Release" / "measure_time.exe"
assert MEASURE_TIME_EXE.is_file()


def measure_time(
operation: Literal["scan", "compact"],
implementation: Literal["cpu", "naive", "efficient", "thrust"],
input_size: int,
block_size: int = -1,
elements_per_thread: int = -1,
) -> float:
result = subprocess.run(
[
str(MEASURE_TIME_EXE),
operation,
implementation,
str(input_size),
str(block_size),
str(elements_per_thread),
],
capture_output=True,
cwd=ROOT_DIR,
check=True,
encoding="utf-8",
text=True,
)
return float(result.stdout)
53 changes: 53 additions & 0 deletions scripts/measure_performance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import json
from pathlib import Path

from helper import measure_time


def main() -> None:
performance_json_path = Path(__file__).parent / "performance.json"
if performance_json_path.exists():
with performance_json_path.open(encoding="utf-8") as f:
performance_data = json.load(f)
else:
performance_data = []

def find_existing_entry(
operation: str, implementation: str, input_size: int
) -> dict | None:
for entry in performance_data:
if (
entry["operation"] == operation
and entry["implementation"] == implementation
and entry["input_size"] == input_size
):
return entry
return None

for implementation in ["cpu", "naive", "efficient", "efficient_plus", "thrust"]:
for exponent in range(4, 28):
base_input_size = 1 << exponent
for input_size in [base_input_size, base_input_size - 3]:
config = {
"operation": "scan",
"implementation": implementation,
"input_size": input_size,
}
if find_existing_entry(**config) is not None:
print(f"Skipping existing entry: {config}")
continue

time_sum = 0.0
time_count = 10
for _ in range(time_count):
time_sum += measure_time("scan", implementation, input_size)
time = time_sum / time_count
print(f"Measured: {config}, time: {time} ms")
performance_data.append({**config, "time": time})

with performance_json_path.open("w", encoding="utf-8") as f:
json.dump(performance_data, f, indent=4)


if __name__ == "__main__":
main()
Loading