ssloy / tinyrenderer

A brief computer graphics / rendering course
https://github.com/ssloy/tinyrenderer/wiki
Other
20.38k stars 1.97k forks source link

slower result when using omp #140

Open zzycarrot opened 5 months ago

zzycarrot commented 5 months ago

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

fd653ba9ace43bf3f707a4f73c0e103
zzycarrot commented 5 months ago

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?

ssloy commented 5 months ago

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

zzycarrot commented 5 months ago

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

ssloy commented 5 months ago

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

zzycarrot commented 5 months ago

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 ,

ssloy commented 5 months ago

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