[Mesa-dev] [PATCH] r600g-llvm: Crude fix for a race in initialization of the llvm backend

Tom Stellard thomas.stellard at amd.com
Thu Aug 16 11:39:48 PDT 2012


On Thu, Aug 16, 2012 at 07:44:53PM +0200, Mathias Fröhlich wrote:
> 
> Hi,
> 
> > This is likely caused by the fact that the same LLVM Context is used
> > for all threads.  Take a look at the comment starting at
> > src/gallium/auxilary/gallivm/lp_bld_init.c:314
> >
> > You should be able to reproduce this error on llvmpipe as well.
> > Creating a new LLVM Context for each thread should fix this.
> 
> I checked the suggestion, but: Are you sure?
> I think we are using a new context for r* even per compile.
> See radeon_setup_tgsi_llvm.c:1009.
>

You're right.  I missed that.

> I have spent some time now to look into this a little closer:
> The observation is that some pass manager stuff is crashing usually.
> Its from the addPassesToEmitFile call while setting up 
> AMDGPUTargetMachine but if you lock just this it crashes mostly in 
> LLVMAddPromoteMemoryToRegisterPass called from radeon_llvm_finalize_module.
> Locking both with the same mutex appears to work for a few short tests.
>
> Does this ring an other bell at the llvm guys?
> 

I'm not really sure about this one.  It might be worth while to see if
you can reproduce the bug with the r600 backend built with LLVM rather
than Mesa.  I have LLVM and Mesa branches that make this possible:

LLVM: http://cgit.freedesktop.org/~tstellar/llvm/ r600-master
Mesa: cgit.freedesktop.org/~tstellar/mesa/ r600-external-llvm

I haven't tested it in a while, though, so it may not work.

-Tom



> Greetings
> 
> Mathias
> 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list