Macaulay2 / Macaulay2/M2

Threading instability, simultaneous saturate (no canceled tasks)

Open
#2,067 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

threads
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

So in a homogeneous ring, there are times when it would be nice to check if an ideal contains a power of the irrelevant. I was thinking maybe try to saturate with respect to each variable individually. Indeed, in an example I was playing with, saturating with respect to each variable separately (8 variables) takes about 0.5 seconds per variable, but saturating with respect to the maximal ideal takes about 6 seconds.

So I decided to write something to see if could take advantage of multithreading here.

```
threadedSaturate = method();

threadedSaturate(Ideal, List) := (I1, L1) -> (
taskList := apply(L1, z -> createTask(saturate, (I1, ideal(z))) );
apply(taskList, t -> schedule t);
while true do (
nanosleep 1000000; --one thousandth of a second
if (all(taskList, t -> isReady(t))) then break;
);
resultList = apply(taskList, t -> taskResult(t));
return resultList
);
```
Unfortunately, it frequently (but not always) gives errors (which become worse the higher `allowableThreads` is).

For example, `allowableThreads = 4` sometimes gives me things like (notice it looks like one of the threads crashed and didn't return an ideal).
```
elapsedTime threadedSaturate(J3, first entries gens mm)
/usr/share/Macaulay2/Core/intersect.m2:41:24:(1):[23]: error: intersect: expected at least one object
/usr/share/Macaulay2/Core/methods.m2:105:83:(1):[22]: --back trace--
/usr/share/Macaulay2/Core/option.m2:16:8:(1):[21]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:105:83:(1):[19]: --back trace--
/usr/share/Macaulay2/Saturation.m2:495:14:(2):[17]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:559:51:(1):[16]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:573:23:(1):[15]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:572:26:(1):[14]: --back trace--
/usr/share/Macaulay2/Core/option.m2:38:8:(1):[13]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:119:80:(1):[12]: --back trace--
/usr/share/Macaulay2/Core/option.m2:38:8:(1):[11]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:565:83:(1):[10]: --back trace--
/usr/share/Macaulay2/Core/option.m2:38:8:(1):[9]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:119:80:(1):[8]: --back trace--
/usr/share/Macaulay2/Core/option.m2:38:8:(1):[7]: --back trace--
/usr/share/Macaulay2/Saturation.m2:418:9:(2):[6]: --back trace--
/usr/share/Macaulay2/Saturation.m2:140:23:(2):[5]: --back trace--
/usr/share/Macaulay2/Saturation.m2:425:10:(2):[4]: --back trace--
/usr/share/Macaulay2/Saturation.m2:367:62:(2):[3]: --back trace--
/usr/share/Macaulay2/Core/methods.m2:119:80:(1):[2]: --back trace--
/usr/share/Macaulay2/Core/option.m2:16:8:(1):[1]: --back trace--
/usr/share/Macaulay2/Core/option.m2:16:8:(1): --back trace--
-- 1.50479 seconds elapsed

o44 = {, ideal 1, ideal 1, ideal 1, ideal 1, ideal 1, ideal 1, ideal 1}

o44 : List
```
On the other hand, it is nearly a linear increase in speed (4 threads is 1.5 seconds).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the saturation paths in Saturation.m2 and the intersect call reported in Core/intersect.m2, then trace how createTask, schedule, isReady, and taskResult handle failures or missing results. Reproduce the threadedSaturate example with different allowableThreads values and verify that every task returns an ideal without errors.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.