From 13bf59dcc8fca3338bff58d99529ef40a287a2b6 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 24 Aug 2021 18:30:15 +0900 Subject: [PATCH] Experimental: remove use of mutex when threaded In theory, it seems that each pixel is only written to once, regardless of how many threads there are. Theoretically, this means that locks are not required. --- example02_threaded_raytracing/src/rayTracer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example02_threaded_raytracing/src/rayTracer.cpp b/example02_threaded_raytracing/src/rayTracer.cpp index 28c6b29..396711b 100644 --- a/example02_threaded_raytracing/src/rayTracer.cpp +++ b/example02_threaded_raytracing/src/rayTracer.cpp @@ -429,7 +429,7 @@ Ex02::RT::Image Ex02::RT::renderColorsWithSpheres(unsigned int outputWidth, } } else { std::vector threads; - std::mutex mutex; + // std::mutex mutex; unsigned int range = outputHeight / threadCount; for (unsigned int threadIdx = 0; threadIdx < threadCount; ++threadIdx) { unsigned int start = range * threadIdx; @@ -444,7 +444,7 @@ Ex02::RT::Image Ex02::RT::renderColorsWithSpheres(unsigned int outputWidth, yIteration(y, mutex); } }, - start, end, &mutex)); + start, end, nullptr)); } for (std::thread &thread : threads) { thread.join();