TheDigitalFrontier / parallel-decision-trees

Semester project in CS205 Computing Foundations for Computational Science at Harvard School of Engineering and Applied Sciences, spring 2020.
MIT License
3 stars 1 forks source link

Running consecutive scripts occasionally fails #104

Open johannes-kk opened 4 years ago

johannes-kk commented 4 years ago

Compiling /speedup/rf_serial.cpp then /speedup/rf_openmp.cpp followed by running one after the other causes the second fo fail. See screenshot below.

However, if the first script is compiled and immediately run, then the second script compiled and run, the problem does not occur. Running the same script several times after compilation also works fine.

@gpestre could it be because we have a memory leakage whereby objects persist between sessions?

image.png

johannes-kk commented 4 years ago

I think OpenMP is the culprit. After parallelising DecisionTree.predict() per #105 , running the same compiled executable twice in a row causes the second run to fail because the assert assert(this->isFitted()) in decision_tree.cpp ln 391 to fail. This happens every time it's tried.

However, if the executable is re-compiled, it works just fine. It even works without re-compiling by changing export OMP_NUM=8 to any other number than the current number of threads, as that presumably triggers some cleaning of OMP.