I forgot to ask:
a) on this laptop, running a Ryzen 7 *, I configure J to use a random
4 of the 8 available cores. As that seems
to work ok, I've stuck with this use for a few years. Does this
affect the allocation of threads. Would it be
better to use all 8 cores for J by default?
b) it's running Windows 11 Home edition. Do either Task Manager or
Performance Manager, or perhaps something
else, provide a means of inspecting a thread's performance?
Cheers,
Mike
* Windows "about" reveals: AMD Ryzen 7 3700U with Radeon Vega Mobile
Gfx 2.30 GHz
On 09/04/2022 20:04, Henry Rich wrote:
The big news in J904 is multithreading. J verbs can now be run in
different cores, sharing the J global namespaces.
[A version of J with limited support for multithreading was revealed
last year by John Ference of Monument AI. John's work was an
important proof of concept, but the J904 version is an independent
development using pthreads instead of OpenMP. John has agreed with
Jsoftware to give Jsoftware access to the code and testcases used in
his work. We have not used the code.]
Two primitives support multithreading:
(0 T. '') creates a thread on a new core. A thread running a verb
is called a /task/. Even if you don't plan to create tasks, you should
create threads to allow JE to use them for its own purposes.
([x] u t. '' y) executes ([x] <@:u y) as a task to produce a boxed
result. The thread that executed t. continues to run. But the result
is a special kind of box called a /pyx/.
['pyx' is Greek for box, and has been brought into English on occasion
when a word has been needed for a special box. The most recent such
borrowing until now is for the box used by the Royal Mint to hold
coins for assay.]
A pyx looks on the outside like any other box. You can pass it as an
argument. But as soon as you look inside it, your thread is blocked
until the task producing the pyx's value has completed. Then you see
the value, and your thread continues.
Tasks share the global namespaces and thus can freely read, write,
stomp on, and delete names visible to other tasks.
We encourage you to experiment with threads and tasks. We are sure
that a layer of synchronizing primitives - semaphores, locks, and
mutexes - will be needed, but we would like to get practical
experience with tasks before we implement them. Suggestions welcome.
Henry Rich
--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm