[Mesa-dev] [Mesa3d-dev] Softpipe and OpenMP
Chih-Sheng Lin
patrickcslin at gmail.com
Mon Jun 8 00:33:20 PDT 2015
Hi,
I am working on parallelizing softpipe of Mesa-9.1 by using OpenMP.
My idea is trying to do sp_setup_tri in parallel with multiple threads.
So first in the function sp_vbuf_draw_elements, I duplicate setup_context
for avoiding race condition
And then sp_setup_tri is set to OpenMP parallel sections with the separate
auguments
The code is as follows:
sp_vbuf_draw_elements(struct vbuf_render *vbr, const ushort *indices, uint
nr)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
struct softpipe_context *softpipe = cvbr->softpipe;
const unsigned stride = softpipe->vertex_info_vbuf.size * sizeof(float);
const void *vertex_buffer = cvbr->vertex_buffer;
struct setup_context *setup = cvbr->setup;
/*duplicate setup context*/
struct setup_context *setup_0, *setup_1;
if(cvbr->prim == PIPE_PRIM_TRIANGLES)
{
setup_0 = sp_setup_create_context(cvbr->setup);
setup_1 = sp_setup_create_context(cvbr->setup);
}
...
case PIPE_PRIM_TRIANGLES:
/*
for (i = 2; i < nr; i += 3) {
sp_setup_tri( setup,
get_vert(vertex_buffer, indices[i-2], stride),
get_vert(vertex_buffer, indices[i-1], stride),
get_vert(vertex_buffer, indices[i-0], stride) );
}
*/
/*parallelizing sp_setup_tri by OpenMP parallel sections*/
if(nr==6)
{
#pragma omp parallel sections
{
#pragma omp section
sp_setup_tri(setup_0, get_vert(vertex_buffer, indices[0], stride),
get_vert(vertex_buffer, indices[1], stride),get_vert(vertex_buffer,
indices[2], stride));
#pragma omp section
sp_setup_tri(setup_1, get_vert(vertex_buffer, indices[3], stride),
get_vert(vertex_buffer, indices[4], stride),get_vert(vertex_buffer,
indices[5], stride));
}
}
sp_setup_destroy_context(setup_0);
sp_setup_destroy_context(setup_1);
break;
And I rebuild mesa and run one test called CPUOverheadTest_onscreen from
GFXBench 2.7.5
I set OMP_NUM_THREADS=2 and the resolution is 1280x900, it gains 10%
performance improvements comparing to OMP_NUM_THREADS=1
However, the test result is not correct, but it works very well comparing
to my first attempt on parallelization
Could someone give me a guide or suggestions for this work?
Thanks in advance!
Patrick Lin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150608/29110953/attachment.html>
More information about the mesa-dev
mailing list