Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple threads and verbose output lead to intermingled output #16

Closed
sfiruch opened this issue Dec 17, 2017 · 2 comments
Closed

Multiple threads and verbose output lead to intermingled output #16

sfiruch opened this issue Dec 17, 2017 · 2 comments

Comments

@sfiruch
Copy link

sfiruch commented Dec 17, 2017

When I run clasp 3.3.3 with a single thread, everything works as expected:

clasp -t1 -V3 test.dimacs
...
v 36971 -36972 -36973 -36974 -36975 -36976 -36977 -36978 -36979 -36980 36981
v 36982 -36983 -36984 -36985 -36986 -36987 -36988 -36989 -36990 -36991 -36992
v -36993 -36994 36995 36996 -36997 -36998 -36999 -37000 -37001 -37002 -37003
v -37004 -37005 -37006 -37007 37008 37009 -37010 -37011 -37012 -37013 -37014
v -37015 -37016 -37017 -37018 -37019 37020 37021 -37022 -37023 -37024 -37025
v -37026 -37027 -37028 -37029 -37030 37031 37032 -37033 -37034 -37035 -37036
v -37037 -37038 -37039 -37040 -37041 -37042 37043 37044 -37045 -37046 -37047
...

If I allow clasp to use more than one thread, the following thing happens:

clasp -t2 -V3 test.dimacs
...
v 36971 -36972 -36973 -36974 -36975 -36976 -36977 -36978 -36979 -36980 36981
v 36982 -36983 -36984 -36985 -36986 -36987 -36988 -36989 -36990 -36991 -36992
v -36993 -36994 36995 36996 -36997 -36998 -36999 -37000 -37001 -37002 -37003
v -37004 -37005 -37006c  0:R|  28497/26173  |  157182/1797    |      6797/0.198 |    1803/2000000   |
 -37007 37008 37009 -37010 -37011 -37012 -37013 -37014
v -37015 -37016 -37017 -37018 -37019 37020 37021 -37022 -37023 -37024 -37025
v -37026 -37027 -37028 -37029 -37030 37031 37032 -37033 -37034 -37035 -37036
v -37037 -37038 -37039 -37040 -37041 -37042 37043 37044 -37045 -37046 -37047

Note how a c-line starts right in the middle of a v-line.

It appears that both threads are writing without synchronization. I can reliably reproduce the problem on Win10, x64, both when writing to StdOut and when redirecting output to a file.

@BenKaufmann
Copy link
Contributor

Hi,
this is actually by design. clasp currently only synchronizes output of models (i.e. v lines of different models won't intermingle) and ensures that individual comments lines are printed as a whole. However, during solving it does not do any synchronization between comment lines (which are mostly intended for debugging/informational purposes) and output of models and/or optimization values as this would complicate the design and slow down solving.

One compromise between full synchronization and intermingled output that I could easily implement would be to suppress (and discard) output of comments while a model is printed.

@sfiruch
Copy link
Author

sfiruch commented Dec 22, 2017

That would be great! Making sure that lines with optimization values are printed as a whole would be another way to make the output more useful.

BenKaufmann added a commit that referenced this issue Jan 2, 2018
 * Text output is now synchronization between threads
BenKaufmann added a commit that referenced this issue Jan 2, 2018
 * Text output is now synchronized between threads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants