2023-12-07 02:54:15 +01:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-12-18 14:31:52 +01:00
|
|
|
"execution_count": 1,
|
2023-12-07 02:54:15 +01:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"12"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"using MetagraphOptimization\n",
|
|
|
|
"using BenchmarkTools\n",
|
|
|
|
"\n",
|
|
|
|
"Threads.nthreads()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 6,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"Graph:\n",
|
2023-12-18 14:31:52 +01:00
|
|
|
" Nodes: Total: 15866, DataTask: 7937, ComputeTaskQED_S2: 720, \n",
|
|
|
|
" ComputeTaskQED_Sum: 1, ComputeTaskQED_V: 4320, ComputeTaskQED_S1: 2880, \n",
|
|
|
|
" ComputeTaskQED_U: 8\n",
|
|
|
|
" Edges: 21617\n",
|
|
|
|
" Total Compute Effort: 66249.0\n",
|
|
|
|
" Total Data Transfer: 1.314048e6\n",
|
|
|
|
" Total Compute Intensity: 0.050415966540035065\n"
|
2023-12-07 02:54:15 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"machine = get_machine_info()\n",
|
|
|
|
"model = QEDModel()\n",
|
2023-12-18 14:31:52 +01:00
|
|
|
"process = parse_process(\"ke->kkkkke\", model)\n",
|
2023-12-07 02:54:15 +01:00
|
|
|
"\n",
|
|
|
|
"inputs = [gen_process_input(process) for _ in 1:1e3];\n",
|
|
|
|
"graph = gen_graph(process)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 7,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"Graph:\n",
|
2023-12-18 14:31:52 +01:00
|
|
|
" Nodes: Total: 2234, DataTask: 1121, ComputeTaskQED_S2: 720, \n",
|
|
|
|
" ComputeTaskQED_Sum: 1, ComputeTaskQED_V: 312, ComputeTaskQED_S1: 72, \n",
|
|
|
|
" ComputeTaskQED_U: 8\n",
|
|
|
|
" Edges: 3977\n",
|
|
|
|
" Total Compute Effort: 11313.0\n",
|
|
|
|
" Total Data Transfer: 659712.0\n",
|
|
|
|
" Total Compute Intensity: 0.017148392025611175\n"
|
2023-12-07 02:54:15 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"optimizer = ReductionOptimizer()\n",
|
|
|
|
"\n",
|
2023-12-18 14:31:52 +01:00
|
|
|
"compute_compton = get_compute_function(graph, process, machine)\n",
|
2023-12-07 02:54:15 +01:00
|
|
|
"optimize_to_fixpoint!(optimizer, graph)\n",
|
|
|
|
"graph"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 8,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2023-12-18 14:31:52 +01:00
|
|
|
"Calculated 133942.0 results/s, 11162.0 results/s per thread for QED Process: 'ke->kkkkke' (12 threads)\n"
|
2023-12-07 02:54:15 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"compute_compton_reduced = get_compute_function(graph, process, machine)\n",
|
|
|
|
"outputs = [zero(ComplexF64) for _ in 1:1e6]\n",
|
|
|
|
"\n",
|
|
|
|
"bench_result = @benchmark begin\n",
|
|
|
|
" Threads.@threads :static for i in eachindex(inputs)\n",
|
|
|
|
" outputs[i] = compute_compton_reduced(inputs[i])\n",
|
|
|
|
" end\n",
|
|
|
|
"end\n",
|
|
|
|
"\n",
|
|
|
|
"rate = length(inputs) / (mean(bench_result.times) / 1.0e9)\n",
|
|
|
|
"rate_per_thread = rate / Threads.nthreads()\n",
|
|
|
|
"println(\"Calculated $(round(rate)) results/s, $(round(rate_per_thread)) results/s per thread for $(process) ($(Threads.nthreads()) threads)\")"
|
|
|
|
]
|
2023-12-18 14:31:52 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 9,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"Calculated 17124.0 results/s, 1427.0 results/s per thread for QED Process: 'ke->kkkkke' (12 threads)\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"bench_result = @benchmark begin\n",
|
|
|
|
" Threads.@threads :static for i in eachindex(inputs)\n",
|
|
|
|
" outputs[i] = compute_compton(inputs[i])\n",
|
|
|
|
" end\n",
|
|
|
|
"end\n",
|
|
|
|
"\n",
|
|
|
|
"rate = length(inputs) / (mean(bench_result.times) / 1.0e9)\n",
|
|
|
|
"rate_per_thread = rate / Threads.nthreads()\n",
|
|
|
|
"println(\"Calculated $(round(rate)) results/s, $(round(rate_per_thread)) results/s per thread for $(process) ($(Threads.nthreads()) threads)\")"
|
|
|
|
]
|
2023-12-07 02:54:15 +01:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
2024-03-13 18:51:31 +01:00
|
|
|
"display_name": "Julia 1.10.2",
|
2023-12-07 02:54:15 +01:00
|
|
|
"language": "julia",
|
2024-03-13 18:51:31 +01:00
|
|
|
"name": "julia-1.10"
|
2023-12-07 02:54:15 +01:00
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"file_extension": ".jl",
|
|
|
|
"mimetype": "application/julia",
|
|
|
|
"name": "julia",
|
2024-03-13 18:51:31 +01:00
|
|
|
"version": "1.10.2"
|
2023-12-07 02:54:15 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 4
|
|
|
|
}
|