<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018, 03:29 Yevgeny Rouban via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018 at 3:57 PM Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" target="_blank" rel="noreferrer">nhaehnle@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 22.10.18 16:14, Yevgeny Rouban wrote:<br>
> On Sat, Oct 20, 2018 at 5:08 PM Nicolai Hähnle via llvm-dev <br>
> <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
>     Hi Yevgeny,<br>
> <br>
>     Just to make sure I'm understanding this correctly: When a thread has a<br>
>     non-null option context, then options set in the global context will<br>
>     have no effect at all for that thread. Right? (That's what I would<br>
>     expect and what makes sense to me.)<br>
> <br>
> Yes, but the global context has no effect on your thread only for those <br>
> options that have been changed in this thread's context.<br>
> That is because a thread local copy of an option is created in the <br>
> current thread context when this option is set by this thread or another <br>
> thread with the same option context. If the option has not been set then <br>
> its global value is used.<br>
> For your case, I would suggest that you explicitly set a new thread <br>
> option context for every thread (or thread group) that uses LLVM. This <br>
> way the threads/groups will not affect each other and will use the <br>
> options in the copy-on-write way.<br>
<br>
That's not quite what we'd need, and we can't control all threads -- <br>
Mesa is a library, and so we can't control what other threads are doing.<br>
<br>
That said, it may be possible to add what we need on top of what you're <br>
proposing without too much effort. Basically, we'd need the <br>
ThreadOptionContext to be optionally "opaque" in the sense of hiding <br>
global options.<br>
<br>
Do you actually need the ThreadOptionContext to be "transparent" for <br>
your use case, or is that just an accidental consequence of the current <br>
implementation?<br></blockquote><div><br></div><div>If all threads were bound to a non-null context then there would be no one which initialized the global options. This would result in unset default values. That is why we need the very first thread (that is used to load and initialize LLVM libraries) to have the ThreadOptionContext unset, so the default option values get into the default option storage. Then, I believe, it would be ok to force all threads to have non-null ThreadOptionContexts. In other words we need to identify the library loading thread and the initialization time period while the ThreadOptionContext must be null.</div><div>These are just my thoughts. I have not tried this use model.</div></div></div></blockquote></div></div><div dir="auto">If the global options are not used because every thread has a ThreadOptionContext, wouldn't it work fine to leave the global values uninitialized since nothing is using them? They could be initialized on first use.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>I made the ThreadOptionContext "transparent" to not impose constraints

 that are not needed for the implementation.<br>
</div><div>  <br></div><div>Thanks.<br>-Yevgeny Rouban<br> 

<br></div><div> </div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></div>