Skip to content

Commit 6b53e54

Browse files
committed
Multithread render() now crashes
- removed from new proto.jl (in src/proto) some duplicate code - repro_crash.jl reproduces the crash more concisely also improved tests: - @Ballocs returns number of heap allocations - @test_no_allocs verifies expressions causes no heap allocations TODO_NEXT: - report the crash - try to reproduce the previous working scenario (old proto.jl) - try to isolate what change caused the problem
1 parent 397a114 commit 6b53e54

8 files changed

+775
-189
lines changed

Project.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@ authors = ["Christian Laforte <christian.laforte@gmail.com> and contributors"]
44
version = "0.1.0"
55

66
[deps]
7+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
78
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
9+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
810
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
911
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
1012
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1113
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
14+
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
1215
SIMD = "fdea26ae-647d-5447-a871-4b548cad5224"
1316
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
1417
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
18+
TestEnv = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
1519

1620
[compat]
1721
julia = "1.6"
1822

1923
[extras]
20-
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
2124
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2225

2326
[targets]

src/RayTracingWeekend.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,10 @@ function render(scene::HittableList, cam::Camera{T}, image_width=400,
326326

327327
# Reset the random seeds, so we always get the same images...
328328
# Makes comparing performance more accurate.
329-
reseed!()
329+
reseed!()
330330

331-
Threads.@threads for i in 1:image_height
331+
#Threads.@threads # claforte: uncomment for CRASH?!
332+
for i in 1:image_height
332333
@inbounds for j in 1:image_width # iterate over each row (FASTER?!)
333334
accum_color = SA{T}[0,0,0]
334335
u = convert(T, j/image_width)

src/proto.jl src/old_proto.jl

File renamed without changes.

test/Manifest.toml src/proto/Manifest.toml

+172
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,23 @@ git-tree-sha1 = "940001114a0147b6e4d10624276d56d531dd9b49"
5151
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
5252
version = "1.2.2"
5353

54+
[[BitTwiddlingConvenienceFunctions]]
55+
deps = ["Static"]
56+
git-tree-sha1 = "bc1317f71de8dce26ea67fcdf7eccc0d0693b75b"
57+
uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b"
58+
version = "0.1.1"
59+
5460
[[CEnum]]
5561
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
5662
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
5763
version = "0.4.1"
5864

65+
[[CPUSummary]]
66+
deps = ["Hwloc", "IfElse", "Static"]
67+
git-tree-sha1 = "87b0c9c6ee0124d6c1f4ce8cb035dcaf9f90b803"
68+
uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
69+
version = "0.1.6"
70+
5971
[[Calculus]]
6072
deps = ["LinearAlgebra"]
6173
git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
@@ -80,12 +92,24 @@ git-tree-sha1 = "bf98fa45a0a4cee295de98d4c1462be26345b9a1"
8092
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
8193
version = "0.1.2"
8294

95+
[[CloseOpenIntervals]]
96+
deps = ["ArrayInterface", "Static"]
97+
git-tree-sha1 = "7b8f09d58294dc8aa13d91a8544b37c8a1dcbc06"
98+
uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9"
99+
version = "0.1.4"
100+
83101
[[Clustering]]
84102
deps = ["Distances", "LinearAlgebra", "NearestNeighbors", "Printf", "SparseArrays", "Statistics", "StatsBase"]
85103
git-tree-sha1 = "75479b7df4167267d75294d14b58244695beb2ac"
86104
uuid = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
87105
version = "0.14.2"
88106

107+
[[CodeTracking]]
108+
deps = ["InteractiveUtils", "UUIDs"]
109+
git-tree-sha1 = "9aa8a5ebb6b5bf469a7e0e2b5202cf6f8c291104"
110+
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
111+
version = "1.0.6"
112+
89113
[[ColorTypes]]
90114
deps = ["FixedPointNumbers", "Random"]
91115
git-tree-sha1 = "024fe24d83e4a5bf5fc80501a314ce0d1aa35597"
@@ -104,6 +128,12 @@ git-tree-sha1 = "417b0ed7b8b838aa6ca0a87aadf1bb9eb111ce40"
104128
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
105129
version = "0.12.8"
106130

131+
[[CommonSubexpressions]]
132+
deps = ["MacroTools", "Test"]
133+
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
134+
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
135+
version = "0.3.0"
136+
107137
[[Compat]]
108138
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
109139
git-tree-sha1 = "44c37b4636bc54afac5c574d2d02b625349d6582"
@@ -119,6 +149,12 @@ git-tree-sha1 = "52cb3ec90e8a8bea0e62e275ba577ad0f74821f7"
119149
uuid = "ed09eef8-17a6-5b46-8889-db040fac31e3"
120150
version = "0.3.2"
121151

152+
[[ConstructionBase]]
153+
deps = ["LinearAlgebra"]
154+
git-tree-sha1 = "f74e9d5388b8620b4cee35d4c5a618dd4dc547f4"
155+
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
156+
version = "1.3.0"
157+
122158
[[CoordinateTransformations]]
123159
deps = ["LinearAlgebra", "StaticArrays"]
124160
git-tree-sha1 = "681ea870b918e7cff7111da58791d7f718067a19"
@@ -149,6 +185,18 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
149185
deps = ["Mmap"]
150186
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
151187

188+
[[DiffResults]]
189+
deps = ["StaticArrays"]
190+
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
191+
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
192+
version = "1.0.3"
193+
194+
[[DiffRules]]
195+
deps = ["LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
196+
git-tree-sha1 = "9bc5dac3c8b6706b58ad5ce24cffd9861f07c94f"
197+
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
198+
version = "1.9.0"
199+
152200
[[Distances]]
153201
deps = ["LinearAlgebra", "SparseArrays", "Statistics", "StatsAPI"]
154202
git-tree-sha1 = "3258d0659f812acde79e8a74b11f17ac06d0ca04"
@@ -205,12 +253,25 @@ git-tree-sha1 = "2db648b6712831ecb333eae76dbfd1c156ca13bb"
205253
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
206254
version = "1.11.2"
207255

256+
[[FileWatching]]
257+
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
258+
208259
[[FixedPointNumbers]]
209260
deps = ["Statistics"]
210261
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
211262
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
212263
version = "0.8.4"
213264

265+
[[ForwardDiff]]
266+
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions", "StaticArrays"]
267+
git-tree-sha1 = "2b72a5624e289ee18256111657663721d59c143e"
268+
uuid = "f6369f11-7733-5829-9624-2563aa707210"
269+
version = "0.10.24"
270+
271+
[[Future]]
272+
deps = ["Random"]
273+
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
274+
214275
[[Graphics]]
215276
deps = ["Colors", "LinearAlgebra", "NaNMath"]
216277
git-tree-sha1 = "1c5a84319923bea76fa145d49e93aa4394c73fc2"
@@ -223,6 +284,24 @@ git-tree-sha1 = "92243c07e786ea3458532e199eb3feee0e7e08eb"
223284
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
224285
version = "1.4.1"
225286

287+
[[HostCPUFeatures]]
288+
deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"]
289+
git-tree-sha1 = "8f0dc80088981ab55702b04bba38097a44a1a3a9"
290+
uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0"
291+
version = "0.1.5"
292+
293+
[[Hwloc]]
294+
deps = ["Hwloc_jll"]
295+
git-tree-sha1 = "92d99146066c5c6888d5a3abc871e6a214388b91"
296+
uuid = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
297+
version = "2.0.0"
298+
299+
[[Hwloc_jll]]
300+
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
301+
git-tree-sha1 = "3395d4d4aeb3c9d31f5929d32760d8baeee88aaf"
302+
uuid = "e33a78d0-f292-5ffc-b300-72abe9b543c8"
303+
version = "2.5.0+0"
304+
226305
[[IfElse]]
227306
git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1"
228307
uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
@@ -408,6 +487,18 @@ git-tree-sha1 = "d735490ac75c5cb9f1b00d8b5509c11984dc6943"
408487
uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8"
409488
version = "2.1.0+0"
410489

490+
[[JuliaInterpreter]]
491+
deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
492+
git-tree-sha1 = "e273807f38074f033d94207a201e6e827d8417db"
493+
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
494+
version = "0.8.21"
495+
496+
[[LayoutPointers]]
497+
deps = ["ArrayInterface", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static"]
498+
git-tree-sha1 = "83b56449c39342a47f3fcdb3bc782bd6d66e1d97"
499+
uuid = "10f19ff3-798f-405d-979b-55457f8fc047"
500+
version = "0.1.4"
501+
411502
[[LazyArtifacts]]
412503
deps = ["Artifacts", "Pkg"]
413504
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
@@ -450,6 +541,18 @@ version = "0.3.6"
450541
[[Logging]]
451542
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
452543

544+
[[LoopVectorization]]
545+
deps = ["ArrayInterface", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "Requires", "SIMDDualNumbers", "SLEEFPirates", "Static", "ThreadingUtilities", "UnPack", "VectorizationBase"]
546+
git-tree-sha1 = "9e10579c154f785b911d9ceb96c33fcc1a661171"
547+
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
548+
version = "0.12.99"
549+
550+
[[LoweredCodeUtils]]
551+
deps = ["JuliaInterpreter"]
552+
git-tree-sha1 = "491a883c4fef1103077a7f648961adbf9c8dd933"
553+
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
554+
version = "2.1.2"
555+
453556
[[MKL_jll]]
454557
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
455558
git-tree-sha1 = "5455aef09b40e5020e1520f551fa3135040d4ed0"
@@ -462,6 +565,11 @@ git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf"
462565
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
463566
version = "0.5.9"
464567

568+
[[ManualMemory]]
569+
git-tree-sha1 = "9cb207b18148b2199db259adfa923b45593fe08e"
570+
uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667"
571+
version = "0.1.6"
572+
465573
[[MappedArrays]]
466574
git-tree-sha1 = "e8b359ef06ec72e8c030463fe02efe5527ee5142"
467575
uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
@@ -586,6 +694,12 @@ git-tree-sha1 = "a7a7e1a88853564e551e4eba8650f8c38df79b37"
586694
uuid = "eebad327-c553-4316-9ea0-9fa01ccd7688"
587695
version = "0.1.1"
588696

697+
[[PolyesterWeave]]
698+
deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"]
699+
git-tree-sha1 = "a3ff99bf561183ee20386aec98ab8f4a12dc724a"
700+
uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad"
701+
version = "0.1.2"
702+
589703
[[Preferences]]
590704
deps = ["TOML"]
591705
git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a"
@@ -637,6 +751,12 @@ git-tree-sha1 = "01d341f502250e81f6fec0afe662aa861392a3aa"
637751
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
638752
version = "0.4.2"
639753

754+
[[RayTracingWeekend]]
755+
deps = ["BenchmarkTools", "Images", "InteractiveUtils", "LinearAlgebra", "LoopVectorization", "Random", "RandomNumbers", "Revise", "SIMD", "Setfield", "StaticArrays", "TestEnv"]
756+
path = "/home/claforte/.julia/depot/dev/RayTracingWeekend"
757+
uuid = "b397971c-46ae-4b69-a3ef-0d20c73199a6"
758+
version = "0.1.0"
759+
640760
[[Reexport]]
641761
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
642762
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
@@ -654,6 +774,12 @@ git-tree-sha1 = "8f82019e525f4d5c669692772a6f4b0a58b06a6a"
654774
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
655775
version = "1.2.0"
656776

777+
[[Revise]]
778+
deps = ["CodeTracking", "Distributed", "FileWatching", "JuliaInterpreter", "LibGit2", "LoweredCodeUtils", "OrderedCollections", "Pkg", "REPL", "Requires", "UUIDs", "Unicode"]
779+
git-tree-sha1 = "e55f4c73ec827f96cd52db0bc6916a3891c726b5"
780+
uuid = "295af30f-e4ad-537b-8983-00126c2a3abe"
781+
version = "3.2.1"
782+
657783
[[Rotations]]
658784
deps = ["LinearAlgebra", "Quaternions", "Random", "StaticArrays", "Statistics"]
659785
git-tree-sha1 = "dbf5f991130238f10abbf4f2d255fb2837943c43"
@@ -663,9 +789,37 @@ version = "1.1.0"
663789
[[SHA]]
664790
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
665791

792+
[[SIMD]]
793+
git-tree-sha1 = "9ba33637b24341aba594a2783a502760aa0bff04"
794+
uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
795+
version = "3.3.1"
796+
797+
[[SIMDDualNumbers]]
798+
deps = ["ForwardDiff", "IfElse", "SLEEFPirates", "VectorizationBase"]
799+
git-tree-sha1 = "62c2da6eb66de8bb88081d20528647140d4daa0e"
800+
uuid = "3cdde19b-5bb0-4aaf-8931-af3e248e098b"
801+
version = "0.1.0"
802+
803+
[[SIMDTypes]]
804+
git-tree-sha1 = "330289636fb8107c5f32088d2741e9fd7a061a5c"
805+
uuid = "94e857df-77ce-4151-89e5-788b33177be4"
806+
version = "0.1.0"
807+
808+
[[SLEEFPirates]]
809+
deps = ["IfElse", "Static", "VectorizationBase"]
810+
git-tree-sha1 = "1410aad1c6b35862573c01b96cd1f6dbe3979994"
811+
uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa"
812+
version = "0.6.28"
813+
666814
[[Serialization]]
667815
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
668816

817+
[[Setfield]]
818+
deps = ["ConstructionBase", "Future", "MacroTools", "Requires"]
819+
git-tree-sha1 = "0afd9e6c623e379f593da01f20590bacc26d1d14"
820+
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
821+
version = "0.8.1"
822+
669823
[[SharedArrays]]
670824
deps = ["Distributed", "Mmap", "Random", "Serialization"]
671825
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
@@ -752,6 +906,18 @@ version = "0.1.1"
752906
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
753907
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
754908

909+
[[TestEnv]]
910+
deps = ["Pkg"]
911+
git-tree-sha1 = "62f7f56dbc9d2d6b9cfd9745db4ee62293b7b9d0"
912+
uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
913+
version = "1.4.2"
914+
915+
[[ThreadingUtilities]]
916+
deps = ["ManualMemory"]
917+
git-tree-sha1 = "03013c6ae7f1824131b2ae2fc1d49793b51e8394"
918+
uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5"
919+
version = "0.4.6"
920+
755921
[[TiffImages]]
756922
deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "OffsetArrays", "PkgVersion", "ProgressMeter", "UUIDs"]
757923
git-tree-sha1 = "c342ae2abf4902d65a0b0bf59b28506a6e17078a"
@@ -782,6 +948,12 @@ version = "1.0.2"
782948
[[Unicode]]
783949
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
784950

951+
[[VectorizationBase]]
952+
deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "Hwloc", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static"]
953+
git-tree-sha1 = "17e5847bb36730d90801170ecd0ce4041a3dde86"
954+
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
955+
version = "0.21.22"
956+
785957
[[WoodburyMatrices]]
786958
deps = ["LinearAlgebra", "SparseArrays"]
787959
git-tree-sha1 = "de67fa59e33ad156a590055375a30b23c40299d3"

test/Project.toml src/proto/Project.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
33
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
44
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
55
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
7-
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
6+
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
7+
RayTracingWeekend = "b397971c-46ae-4b69-a3ef-0d20c73199a6"
88
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
9-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

0 commit comments

Comments
 (0)