Macaulay2 Engine
Loading...
Searching...
No Matches

◆ start_computation()

void SchreyerFrame::start_computation ( StopConditions & stop)

Definition at line 262 of file res-schreyer-frame.cpp.

263{
264 // This is the computation of the non-minimal maps themselves
265 decltype(timer()) timeA, timeB;
266 // if (level(0).size() == 0)
267 // mState = Done;;
268 computeFrame();
269 if (M2_gbTrace >= 1)
270 {
271 std::cout << "computation status after computing frame: " << std::endl;
272 mComputationStatus.output();
273 }
274
275 int top_slanted_degree = mHiSlantedDegree;
276 if (stop.stop_after_degree and mHiSlantedDegree > stop.degree_limit->array[0])
277 top_slanted_degree = stop.degree_limit->array[0];
278
279#if defined(WITH_TBB)
280 // build the dependency graph
282 {
283 //std::cout << "In dep graph" << std::endl;
284 mScheduler.execute([&] {
285 makeDependencyGraph(mDepGraph,
286 mMaxLength+1,
287 top_slanted_degree - mLoSlantedDegree + 1,
288 false);
289 mDepGraph.startComputation();
290 mDepGraph.waitForCompletion();
291 });
292 //std::cout << "Out dep graph" << std::endl;
293 }
294 else
295 computeSyzygies(top_slanted_degree, mMaxLength);
296#else
297 computeSyzygies(top_slanted_degree, mMaxLength);
298#endif
299
300 if (M2_gbTrace >= 1)
301 {
303 std::cout << "total time for make matrix: " << timeMakeMatrix
304 << std::endl;
305 std::cout << "total time for sort matrix: " << timeSortMatrix
306 << std::endl;
307 std::cout << "total time for reorder matrix: " << timeReorderMatrix
308 << std::endl;
309 std::cout << "total time for gauss matrix: " << timeGaussMatrix
310 << std::endl;
311 std::cout << "total time for clear matrix: " << timeClearMatrix
312 << std::endl;
313 std::cout << "total time for reset hash table: " << timeResetHashTable
314 << std::endl;
315 std::cout << "total time for computing ranks: " << timeComputeRanks
316 << std::endl;
317 std::cout << "total time for computing sparse ranks: " << timeComputeSparseRanks
318 << std::endl;
319 }
320
321 return;
322#if 0
323 if (M2_gbTrace >= 1)
324 {
325 std::cout << "computation status after computing syzygies: " << std::endl;
326 mComputationStatus.output();
327 }
328 timeA = timer();
330 timeB = timer();
331 timeComputeRanks += seconds(timeB-timeA);
332 if (M2_gbTrace >= 1)
333 {
334 std::cout << "computation status after computing ranks: " << std::endl;
335 mComputationStatus.output();
336 }
337
338
339 // This next part needs to be computed after the frame, as otherwise mHiSlantedDegree isn't yet set.
340 int top_slanted_degree = 0;
341
342 top_slanted_degree = mHiSlantedDegree;
343 if (stop.stop_after_degree and mHiSlantedDegree > stop.degree_limit->array[0])
344 top_slanted_degree = stop.degree_limit->array[0];
345
346 while (true)
347 {
348 switch (mState) {
349 case Initializing:
350 break;
351 case Frame:
352 std::cerr << "ERROR: should not get to this point anymore..." << std::endl;
353 if (M2_gbTrace >= 1)
354 std::cout << "maxsize = " << mFrame.mLevels.size() << " and mCurrentLevel = " << mCurrentLevel << std::endl;
355 if (mCurrentLevel >= mFrame.mLevels.size() or computeNextLevel() == 0)
356 {
357 //show(6);
359 mCurrentLevel = 2;
363 if (M2_gbTrace >= 1)
364 {
365 std::cout << "non-minimal betti: " << std::endl;
366 mBettiNonminimal.output();
367 }
368 //for (int i=0; i<mMinimalizeTODO.size(); i++)
369 // {
370 // auto a = mMinimalizeTODO[i];
371 // std::cout << "(" << a.first << "," << a.second << ") ";
372 // }
373 // std::cout << std::endl;
374 }
375 break;
376 case Matrices:
377 if (M2_gbTrace >= 1)
378 std::cout << "start_computation: entering matrices(" << mSlantedDegree << ", " << mCurrentLevel << ")" << std::endl;
379 if (stop.always_stop) return;
380
382 {
383 mCurrentLevel = 2;
385 if (mSlantedDegree > top_slanted_degree)
386 {
387 if (M2_gbTrace >= 1)
389#if 0
391#endif
392 timeA = timer();
393 for (auto it=mMinimalizeTODO.cbegin(); it != mMinimalizeTODO.cend(); ++it)
394 {
395 int rk = rank(it->first, it->second);
396 mBettiMinimal.entry(it->first, it->second) -= rk;
397 mBettiMinimal.entry(it->first+1, it->second-1) -= rk;
398 }
399 timeB = timer();
400 timeComputeRanks += seconds(timeB-timeA);
401 mState = Done;
402 if (M2_gbTrace >= 1)
403 mBettiMinimal.output();
404 break;
405 }
406 // if (stop.stop_after_degree and mSlantedDegree > stop.degree_limit->array[0])
407 // return;
408 }
409 if (M2_gbTrace >= 2)
410 {
411 std::cout << "construct(" << mSlantedDegree << ", " << mCurrentLevel << ")..." << std::endl;
412 }
414 if (M2_gbTrace >= 2)
415 std::cout << "done" << std::endl;
418 break;
419 case Done:
420 if (M2_gbTrace >= 1)
421 {
422 std::cout << "total time for make matrix: " << timeMakeMatrix << std::endl;
423 std::cout << "total time for sort matrix: " << timeSortMatrix << std::endl;
424 std::cout << "total time for reorder matrix: " << timeReorderMatrix << std::endl;
425 std::cout << "total time for gauss matrix: " << timeGaussMatrix << std::endl;
426 std::cout << "total time for clear matrix: " << timeClearMatrix << std::endl;
427 std::cout << "total time for reset hash table: " << timeResetHashTable << std::endl;
428 std::cout << "total time for computing ranks: " << timeComputeRanks << std::endl;
429 }
430 return;
431 default:
432 break;
433 }
434 }
435#endif
436}
std::vector< std::pair< int, int > > mMinimalizeTODO
void computeSyzygies(int slanted_degree, int maxlevel)
void computeRanks(int slanted_degree, int maxlevel)
BettiDisplay mBettiMinimal
int rank(int slanted_degree, int lev)
enum SchreyerFrame::@107076371201376153077324375251043314133302145334 mState
component_index computeNextLevel()
BettiDisplay mComputationStatus
void getBounds(int &loDegree, int &hiDegree, int &length) const
void showMemoryUsage() const
BettiDisplay mBettiNonminimal
bool debugCheckOrderAll() const
std::unique_ptr< F4Res > mComputer
int M2_gbTrace
Definition m2-types.cpp:52
void makeDependencyGraph(int nlevels, int nslanted_degrees)
The full frame: a vector of Levels indexed by homological degree.
M2_bool always_stop
Definition computation.h:91
M2_bool stop_after_degree
Definition computation.h:92
M2_arrayint degree_limit
Definition computation.h:93
std::chrono::steady_clock::time_point timer()
Definition timing.hpp:35
double seconds(DurationType time_diff)
Definition timing.hpp:59

References StopConditions::always_stop, computeFrame(), computeNextLevel(), computeRanks(), computeSyzygies(), debugCheckOrderAll(), StopConditions::degree_limit, Done, getBounds(), Initializing, M2_gbTrace, makeDependencyGraph(), Matrices, mBettiMinimal, mBettiNonminimal, mComputationStatus, mComputer, mCurrentLevel, mFrame, mHiSlantedDegree, mLoSlantedDegree, mMaxLength, mMinimalizeTODO, mParallelizeByDegree, mSlantedDegree, mState, rank(), seconds(), setBettiDisplays(), showMemoryUsage(), StopConditions::stop_after_degree, timeClearMatrix, timeComputeRanks, timeComputeSparseRanks, timeGaussMatrix, timeMakeMatrix, timer(), timeReorderMatrix, timeResetHashTable, and timeSortMatrix.