From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: Toy computational "benchmark" in Ada (new blog post) Date: Thu, 06 Jun 2019 23:38:21 -0700 Organization: A noiseless patient Spider Message-ID: <87imthx5lu.fsf@nightsong.com> References: <55b14350-e255-406c-ab11-b824da77995b@googlegroups.com> <6776b034-1318-49b3-8ff5-5a2f746fac9c@googlegroups.com> <87blzaxnei.fsf@nightsong.com> <877e9yxamb.fsf@nightsong.com> <5425afe3-8e22-4b1b-913c-f274fac7021a@googlegroups.com> <87tvd2vssi.fsf@nightsong.com> <4c95ff02-43c4-44aa-ab65-db688f0c2e17@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="b0f0f522fb2e31df244925cac2903ee1"; logging-data="28822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+D5/V14VLtvuESa7Gg2p5N" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:P7A/I0QoFm5ULf8Jlyc4ZzaiepI= sha1:m2U2nC97bKc0EkBKzW6XQcwWzQA= Xref: reader01.eternal-september.org comp.lang.ada:56530 Date: 2019-06-06T23:38:21-07:00 List-Id: David Trudgett writes: >> Yes I'll see if I can rework the C++ code to not launch new threads at >> each run. > It doesn't matter if you don't time that part of the execution. But > I'm guessing that would be hard in C++. I used the C++ futures/async feature which in principle could use a thread pool, but in GCC 6 I'm told that it launches a new thread for each async. Otherwise I used what I think is the same strategy as the Ada code: for Worker in Worker_Range loop Tasks (Worker).Run (Start_Idx => Idx_Ranges (Worker, Low), Finish_Idx => Idx_Ranges (Worker, High)); end loop; It looks like you have a static array of worker threads, and I'm guessing that the .Run message some kind of event to a worker to tell it to run the task body. I didn't try to figure it all out though. Does Ada automatically create an event loop in each task to receive those messages? If yes, that's pretty cool. Is there a request queue between the main program and each worker? What happens if it gets too large? Is there a way to share a single queue between a bunch of workers? I read "Ada Distilled" some time back but iirc it didn't say much about this. I've been wanting to get a more detailed book.