BLIS for RTL simulators and systemless gem5

39 views
Skip to first unread message

Stepan Nassyr

unread,
Nov 8, 2020, 4:28:52 PM11/8/20
to blis-devel
Hello,
In the context of implementing an SVE version of BLIS, I've been approached by multiple interested parties wanting to run BLIS on system-less gem5 and proprietary RTL simulators. In these cases there is no operating system or a threading environment, therefore pthread cannot be used. In case of gem5 there is also a full system mode that can support pthread - which is what we are currently using - this however comes with some overhead, so there is an incentive here as well. I am not quite sure pthread is the only hurdle to overcome in order to get it working, but it appears to be the first issue that needs to be taken care of.

I have made some naive attempts to disable pthread by hiding pthread* calls in some ifdefs, but ran into issues (I gave up after encountering segfaults, seeing bli_thrinfo_sup_grow in the call stack when calling gemm and deciding I'm in over my head).

How feasible would it be to decouple BLIS from pthread/any threading for this specific purpose? Or without modifying the code -  would something like a "fake" pthread library that just serializes everything work?

Jeff Hammond

unread,
Nov 8, 2020, 4:44:31 PM11/8/20
to Stepan Nassyr, blis-devel
You should be able to build without pthreads with no code changes. There is a sequential build mode. 

You can run a BLIS test program with strace to find the mandatory syscalls used during execution.

Jeff

Sent from my iPhone

On Nov 8, 2020, at 1:28 PM, Stepan Nassyr <s.na...@fz-juelich.de> wrote:

Hello,

In the context of implementing an SVE version of BLIS, I've been approached by multiple interested parties wanting to run BLIS on system-less gem5 and proprietary RTL simulators. In these cases there is no operating system or a threading environment, therefore pthread cannot be used. In case of gem5 there is also a full system mode that can support pthread - which is what we are currently using - this however comes with some overhead, so there is an incentive here as well. I am not quite sure pthread is the only hurdle to overcome in order to get it working, but it appears to be the first issue that needs to be taken care of.

I have made some naive attempts to disable pthread by hiding pthread* calls in some ifdefs, but ran into issues (I gave up after encountering segfaults, seeing bli_thrinfo_sup_grow in the call stack when calling gemm and deciding I'm in over my head).

How feasible would it be to decouple BLIS from pthread/any threading for this specific purpose? Or without modifying the code -  would something like a "fake" pthread library that just serializes everything work?

--
You received this message because you are subscribed to the Google Groups "blis-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blis-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com.

Stepan Nassyr

unread,
Nov 8, 2020, 4:50:42 PM11/8/20
to blis-devel
I assumed that BLIS relies on pthread unconditionally for thread safety from reading https://github.com/flame/blis/issues/247 and looking through the source code. Have I misunderstood something?

Jeff Hammond

unread,
Nov 8, 2020, 4:54:48 PM11/8/20
to Stepan Nassyr, blis-devel
You are correct. I was lazy and responded without reading the code. 


It should be possible to elide pthreads. I can try to help you with that after SC20. 

Jeff

Sent from my iPhone

On Nov 8, 2020, at 1:50 PM, Stepan Nassyr <s.na...@fz-juelich.de> wrote:

I assumed that BLIS relies on pthread unconditionally for thread safety from reading https://github.com/flame/blis/issues/247 and looking through the source code. Have I misunderstood something?

Devin Matthews

unread,
Nov 8, 2020, 8:37:38 PM11/8/20
to blis-...@googlegroups.com
BLIS only uses pthreads in "single-threaded" mode for pthread_once. This should be easy to insert a shim for on a truly single-threaded system.

Devin

Field G. Van Zee

unread,
Nov 9, 2020, 12:14:03 PM11/9/20
to blis-...@googlegroups.com
Perhaps this should be turned into a configure-time option? Something
like "--thread-unsafe" with a description that explains why one would
want to give up thread safety voluntarily.

Shall we open an issue?

Field
>>>> <https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "blis-devel" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to blis-devel+...@googlegroups.com
>>> <mailto:blis-devel+...@googlegroups.com>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/blis-devel/3f2b3b1e-44e2-4889-a423-d609cabecd8fn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/blis-devel/3f2b3b1e-44e2-4889-a423-d609cabecd8fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> --
>> You received this message because you are subscribed to the Google
>> Groups "blis-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to blis-devel+...@googlegroups.com
>> <mailto:blis-devel+...@googlegroups.com>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/blis-devel/D407EA4E-0DEF-466C-A886-FE3980F48CA1%40gmail.com
>> <https://groups.google.com/d/msgid/blis-devel/D407EA4E-0DEF-466C-A886-FE3980F48CA1%40gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "blis-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/blis-devel/848c0286-fd6a-ac6a-816d-164749018a4a%40smu.edu
> <https://groups.google.com/d/msgid/blis-devel/848c0286-fd6a-ac6a-816d-164749018a4a%40smu.edu?utm_medium=email&utm_source=footer>.

Devin Matthews

unread,
Nov 9, 2020, 12:23:31 PM11/9/20
to blis-...@googlegroups.com
I would suggest something like "--without-system" as there may be other
non-threading changes that would fall under that umbrella.

Devin

Minh Quan HO

unread,
Nov 9, 2020, 12:23:31 PM11/9/20
to blis-devel
Maybe we can implement a custom pthread_once() based on a lock-free mutex by atomic builtins in GCC ? https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html

Quan

Minh Quan HO

unread,
Nov 9, 2020, 12:27:23 PM11/9/20
to blis-devel

Jeff Hammond

unread,
Nov 9, 2020, 12:30:49 PM11/9/20
to Devin Matthews, blis-discuss
This is the right way to go.  Unless BLIS plans to support real user on systems that do not have Pthreads, it makes sense to target the use case requested  by Stepan.

Jeff



--

Field G. Van Zee

unread,
Nov 10, 2020, 2:00:15 PM11/10/20
to blis-...@googlegroups.com
I'll start work on this shortly. Once I have something to present, I'll
push it to 'dev', and from there we can make further tweaks if necessary.

Field
> <s.na...@fz-juelich.de <mailto:s.na...@fz-juelich.de>>
> >>>> wrote:
> >>>>
> >>>> I assumed that BLIS relies on pthread unconditionally for thread
> >>>> safety from reading https://github.com/flame/blis/issues/247
> <https://github.com/flame/blis/issues/247> and
> >>>> looking through the source code. Have I misunderstood something?
> >>>>
> >>>> On Sunday, November 8, 2020 at 10:44:31 PM UTC+1 Jeff Hammond
> wrote:
> >>>>
> >>>>     You should be able to build without pthreads with no code
> >>>>     changes. There is a sequential build mode.
> >>>>
> >>>>     You can run a BLIS test program with strace to find the
> mandatory
> >>>>     syscalls used during execution.
> >>>>
> >>>>     Jeff
> >>>>
> >>>>     Sent from my iPhone
> >>>>
> >>>>>     On Nov 8, 2020, at 1:28 PM, Stepan Nassyr
> <mailto:blis-devel%2B...@googlegroups.com>.
> >>>>>     To view this discussion on the web visit
> >>>>>
> https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com
> <https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com>
> >>>>>
> <https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/blis-devel/0742385c-6c65-45ae-bc0e-f45b0e97607en%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> >>>>
> >>>> --
> >>>> You received this message because you are subscribed to the
> Google
> >>>> Groups "blis-devel" group.
> >>>> To unsubscribe from this group and stop receiving emails from it,
> >>>> send an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>
> >>>> <mailto:blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/blis-devel/3f2b3b1e-44e2-4889-a423-d609cabecd8fn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/blis-devel/3f2b3b1e-44e2-4889-a423-d609cabecd8fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> >>>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "blis-devel" group.
> >>> To unsubscribe from this group and stop receiving emails from it,
> >>> send an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>
> >>> <mailto:blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/blis-devel/D407EA4E-0DEF-466C-A886-FE3980F48CA1%40gmail.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/blis-devel/D407EA4E-0DEF-466C-A886-FE3980F48CA1%40gmail.com?utm_medium=email&utm_source=footer>>.
>
> >>>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "blis-devel" group.
> >> To unsubscribe from this group and stop receiving emails from it,
> >> send an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>
> >> <mailto:blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/blis-devel/848c0286-fd6a-ac6a-816d-164749018a4a%40smu.edu?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/blis-devel/848c0286-fd6a-ac6a-816d-164749018a4a%40smu.edu?utm_medium=email&utm_source=footer>>.
>
> >>
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "blis-devel" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/blis-devel/9ab68a9d-28fa-cc99-75e8-9314cd9476c7%40smu.edu
> <https://groups.google.com/d/msgid/blis-devel/9ab68a9d-28fa-cc99-75e8-9314cd9476c7%40smu.edu>.
>
>
>
> --
> Jeff Hammond
> jeff.s...@gmail.com <mailto:jeff.s...@gmail.com>
> http://jeffhammond.github.io/ <http://jeffhammond.github.io/>
>
> --
> You received this message because you are subscribed to the Google
> Groups "blis-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to blis-devel+...@googlegroups.com
> <mailto:blis-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/blis-devel/CAGKz%3DuJp5fAwsqLPB6tpS9K1pcc60WOLO_ceqfoY4-QxOYTFTQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/blis-devel/CAGKz%3DuJp5fAwsqLPB6tpS9K1pcc60WOLO_ceqfoY4-QxOYTFTQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Field G. Van Zee

unread,
Nov 10, 2020, 2:07:53 PM11/10/20
to blis-...@googlegroups.com
Let's take this discussion to [1] henceforth. Thanks everyone.

[1] https://github.com/flame/blis/issues/454
Reply all
Reply to author
Forward
0 new messages