souffle-lang / souffle

Soufflé is a variant of Datalog for tool designers crafting analyses in Horn clauses. Soufflé synthesizes a native parallel C++ program from a logic specification.
http://souffle-lang.github.io/
Universal Permissive License v1.0
916 stars 207 forks source link

Context variable not used when compiling C++ client code with modified SouffleInterface.h and CompileSouffle.h #1137

Closed NubKel closed 4 years ago

NubKel commented 5 years ago

This is Kelvin from the 2019 capstone team, we are doing the C++ interface enhancement task. Which we attempted to solve problems such as checking the element before the insertion (related to issue #1075.), using std lib data structure instead of using tuple (in Souffle) in client operation. When we are testing, we get the result we want, however, we also get the issue of "variable set but not used". In generated C++ file, the rel_1_edge_op_ctxt in CREATE_OP_CONTEXT(rel_1_edge_op_ctxt,rel_1_edge->createContext()); has never used, which oppositely the relation edge is the one that used operated in the client code.

Can someone explain what CREATE_OP_CONTEXT(NAME, INIT) does in ParallelUtils.h and the concept of "context"? Thanks!

XiaowenHu96 commented 5 years ago

I don't think the issue is related to the files you modified. The Synthesiser.cpp does create unnecessary context in some cases:

For example, in RamExistenceCheck, a context should be created only for partial existence check. However, in special cases, RamExistenceCheck can have an empty or full search signature, which can be simplified to a non-empty check and a full-order search. Both operations actually don't need a context but the synthesiser create it anyway.

We can add an extra check in the synthesiser to avoid unnecessary context creation.

b-scholz commented 5 years ago

This is related to the synthesizer. We haven't disabled the warnings while compiling.

mmcgr commented 4 years ago

We use a fairly simple approach to determine which relations are related, and add a context variable for all of them. In some cases this will add an unused variable. This unused variable produces a warning when we compile synthesised code but is harmless. More accurate tests for whether a context variable is relevant are also more complicated, and are not a priority.

It's possible this will be changed in the future as part of some other changes, but we don't plan to change this for now.