summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 02:16:48 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 02:16:48 +0000
commitf1558e4afd2afe5b23c4ecf9fb4de0415068cc02 (patch)
tree02d6ff49e49127cce30a771f48eea0c6ff18aa7a
parentd8fa7f3e9b8127911996c36f477bcae3831f7708 (diff)
l2r bugfixes
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@636 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-xdecoder/apply_fsa_models.cc20
-rw-r--r--utils/d_ary_heap.h4
2 files changed, 20 insertions, 4 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc
index 83083fc5..4bf4e031 100755
--- a/decoder/apply_fsa_models.cc
+++ b/decoder/apply_fsa_models.cc
@@ -21,6 +21,8 @@
#include "show.h"
#include "string_to.h"
+#define SAFE_VALGRIND 1
+
#define DFSA(x) x
//fsa earley chart
@@ -494,9 +496,23 @@ struct Item;
typedef Item *ItemP;
/* we use a single type of item so it can live in a single best-first queue. we hold them by pointer so they can have mutable state, e.g. priority/location, but also lists of predictions and kbest completions (i.e. completions[L,r] = L -> * (r,s), by 1best for each possible s. we may discover more s later. we could use different subtypes since we hold by pointer, but for now everything will be packed as variants of Item */
+#undef INIT_LOCATION
+#if D_ARY_TRACK_OUT_OF_HEAP
+# define INIT_LOCATION , location(D_ARY_HEAP_NULL_INDEX)
+#elsif !defined(NDEBUG) || SAFE_VALGRIND
+ // avoid spurious valgrind warning
+# define INIT_LOCATION , location()
+#else
+# define INIT_LOCATION
+#endif
+
struct Item : ItemPrio,ItemKey {
- explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { }
- explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { }
+ explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0)
+ INIT_LOCATION
+ { }
+ explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0)
+ INIT_LOCATION
+ { }
typedef std::queue<ItemP> Predicted;
Predicted predicted; // this is empty, unless this is a predicted L -> .asdf item, or a to-complete L -> asdf .
int next; // index of dot->adj to complete (if dest==0), or predict (if NT), or scan (if word). note: we could store pointer inside adj since it and trie are @ fixed addrs. less pointer arith, more space.
diff --git a/utils/d_ary_heap.h b/utils/d_ary_heap.h
index 20cdab95..606382c2 100644
--- a/utils/d_ary_heap.h
+++ b/utils/d_ary_heap.h
@@ -8,12 +8,12 @@
#define D_ARY_UP_GRAEHL 0 // untested
#define D_ARY_APPEND_ALWAYS_PUSH 1 // heapify (0) is untested. otherwise switch between push and heapify depending on size (cache effects, existing items vs. # appended ones)
-#define D_ARY_TRACK_OUT_OF_HEAP 1 // shouldn't need to track, because in contains() false positives looking up stale or random loc map values are impossible - we just check key
+#define D_ARY_TRACK_OUT_OF_HEAP 0 // shouldn't need to track, because in contains() false positives looking up stale or random loc map values are impossible - we just check key. note: if you enable this, you must init location to D_ARY_HEAP_NULL_INDEX yourself until it's been added or popped
#define D_ARY_VERIFY_HEAP 1
// This is a very expensive test so it should be disabled even when NDEBUG is not defined
# undef D_ARY_HEAP_NULL_INDEX
-# define D_ARY_HEAP_NULL_INDEX (-1) // if you want to test contains before adding, init location to this.
+# define D_ARY_HEAP_NULL_INDEX (-1) // you may init location to this.
/* adapted from boost/graph/detail/d_ary_heap.hpp