From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Parallel Sieve Of Eratosthenes Date: Mon, 1 Jul 2024 11:17:09 +0200 Organization: Adalog Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 01 Jul 2024 11:17:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="c6375fbce5b91ff19f9ff56ffb511f89"; logging-data="1064174"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jsj3NRyETZkr8U7xlQXlO" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:wT9h4iT+B7EMOUfjEX0pinm/Bb8= Content-Language: en-US, fr In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:66211 List-Id: Le 01/07/2024 à 02:02, Lawrence D'Oliveiro a écrit : > On Sun, 30 Jun 2024 18:36:45 +0200, J-P. Rosen wrote: > >> That's because in your first version, you call the child within the >> accept statement. Therefore you wait for the value to go to the end of >> the pipeline before processing the next value. >> Try to copy the number to a variable, and call the child after the end >> of the accept. This will give you 100% CPU time usage. >> >> BTW, you don't need an access type. Just use a declare block to create >> the child after the first accept. > > Thanks for the comments, how about this slight rework of the first > version. It does seem faster, but I’m not sure it’s as fast as the second > version. That's better, but as a general principle, you should move as much as you can out of the rendezvous (minimize critical sequences). For example: accept next_int(i : integer) do my_prime := i; end next_int; Text_IO.Put_line(integer'image(my_prime)); -- moved declare subchild : offspring; ii : integer; begin loop accept next_int(i : integer) do ii := i; end next_int; if ii mod my_prime /= 0 then --moved subchild.next_int(ii); end if; end loop; -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX https://www.adalog.fr https://www.adacontrol.fr