tinyrenderer icon indicating copy to clipboard operation
tinyrenderer copied to clipboard

slower result when using omp

Open zzycarrot opened this issue 1 year ago • 7 comments

when writting the Triangle() function ,i get a much slower result when i used omp parallel,(2 times slower infact), fd653ba9ace43bf3f707a4f73c0e103

zzycarrot avatar Apr 19 '24 08:04 zzycarrot

我已经收到您的邮件了,我将会尽快处理,保持联系!

DouYuexi avatar Apr 19 '24 08:04 DouYuexi

is it because the variable "image" was locked when it was been written that other threads can't use it ,which resulted in a slower speed than serial computing?

zzycarrot avatar Apr 19 '24 08:04 zzycarrot

Is the behavior same with a simple #pragma omp parallel for ? (i mean without collapse/scheduling)

ssloy avatar Apr 19 '24 08:04 ssloy

Is the behavior same with a simple #pragma omp parallel for ? (i mean without collapse/scheduling)

yes it is, i've tried a simple #pragma omp parallel for but with the same result

zzycarrot avatar Apr 19 '24 09:04 zzycarrot

I am curious. Can you try the code from master branch in my repository with and without this #pragma ? https://github.com/ssloy/tinyrenderer/blob/6d3acdb9ee452449b528ef3900ef5528dad0f807/our_gl.cpp#L41

ssloy avatar Apr 19 '24 10:04 ssloy

I am curious. Can you try the code from master branch in my repository with and without this #pragma ?

https://github.com/ssloy/tinyrenderer/blob/6d3acdb9ee452449b528ef3900ef5528dad0f807/our_gl.cpp#L41 i've tried yours now and it's performing as it should be (faster with omp) , maybe i've written my code wrongly ,

zzycarrot avatar Apr 19 '24 10:04 zzycarrot

i see nothing wrong with your code, if you find the problem please share

ssloy avatar Apr 19 '24 11:04 ssloy