From bastian.abt at mailbox.org Fri Feb 7 09:35:58 2025 From: bastian.abt at mailbox.org (bastian.abt at mailbox.org) Date: Fri, 07 Feb 2025 09:35:58 +0100 Subject: [GiNaC-list] using GiNaC in a multithreaded environment Message-ID: An HTML attachment was scrubbed... URL: From V.Kisil at leeds.ac.uk Sat Feb 8 12:12:59 2025 From: V.Kisil at leeds.ac.uk (Vladimir V. Kisil) Date: Sat, 8 Feb 2025 11:12:59 +0000 Subject: [GiNaC-list] using GiNaC in a multithreaded environment In-Reply-To: References: Message-ID: <65231.1739013177@zbook-hp.Home> Hello, I do not think multi-threading is possible with GiNaC, you may want to read one of the past discussion of this starting from here: https://www.ginac.de/pipermail/ginac-list/2010-August/001715.html Best wishes, Vladimir -- Vladimir V. Kisil http://v-v-kisil.scienceontheweb.net Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories >>>>> On Fri, 07 Feb 2025 09:35:58 +0100, Bastian via GiNaC-list said: > Hello, I have a rather large number of expressions, > which I must normalize. To increase performance I wanted to > implement this on multiple threads. However, this always > segfaults and I am having trouble to find out where my error > is. Consider the following code: > ```c++ // H is a 9x9 matrix void norm_matrix(GiNaC::matrix& H) { > thread_pool tp = thread_pool(); auto n = 9; > std::vector> futures(n*n); for(int r = 0; r > < n; ++r) { for(int c = 0; c < n; ++c) { futures[r*n+c] = > tp.submit( [&h = H(r,c)] () -> GiNaC::ex { return h.normal(); }); > } } > for(int r = 0; r < n; ++r) { for(int c = 0; c < n; ++c) { > H(r,c) = futures[r*n+c].get(); } } } ``` At the second iterations > on the call of h.normal(), this crashes with a segfault, both with > a reference as well as with a copy. Has GiNaC been used in a > multithreaded environment previously and has this error occured? > Kind regards Spooky Ghost