ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
heap.h File Reference
#include "stack.h"
#include "utilities.h"
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include "global.h"
Include dependency graph for heap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  heap
 

Macros

#define DISCONTAIN   UINT_MAX
 
#define DISCONTAINED(IDX)
 
#define kissat_check_heap(...)
 

Typedefs

typedef struct heap heap
 

Functions

void kissat_resize_heap (struct kissat *, heap *, unsigned size)
 
void kissat_release_heap (struct kissat *, heap *)
 
void kissat_rescale_heap (struct kissat *, heap *heap, double factor)
 
void kissat_enlarge_heap (struct kissat *, heap *, unsigned new_vars)
 

Macro Definition Documentation

◆ DISCONTAIN

#define DISCONTAIN   UINT_MAX

Definition at line 14 of file heap.h.

◆ DISCONTAINED

#define DISCONTAINED ( IDX)
Value:
((int) (IDX) < 0)
#define IDX(LIT)
Definition literal.h:28

Definition at line 15 of file heap.h.

◆ kissat_check_heap

#define kissat_check_heap ( ...)
Value:
do { \
} while (0)

Definition at line 83 of file heap.h.

83#define kissat_check_heap(...) \
84 do { \
85 } while (0)

Typedef Documentation

◆ heap

typedef struct heap heap

Definition at line 17 of file heap.h.

Function Documentation

◆ kissat_enlarge_heap()

void kissat_enlarge_heap ( struct kissat * solver,
heap * heap,
unsigned new_vars )

Definition at line 82 of file heap.c.

82 {
83 const unsigned old_vars = heap->vars;
84 KISSAT_assert (old_vars < new_vars);
85 KISSAT_assert (new_vars <= heap->size);
86 const size_t delta = new_vars - heap->vars;
87 memset (heap->pos + old_vars, 0xff, delta * sizeof (unsigned));
88 heap->vars = new_vars;
89 if (heap->tainted)
90 memset (heap->score + old_vars, 0, delta * sizeof (double));
91 LOG ("enlarged heap from %u to %u", old_vars, new_vars);
92#ifndef LOGGING
93 (void) solver;
94#endif
95}
#define LOG(...)
#define KISSAT_assert(ignore)
Definition global.h:13
#define solver
Definition kitten.c:211
Definition heap.h:19
unsigned * pos
Definition heap.h:25
double * score
Definition heap.h:24
unsigned vars
Definition heap.h:21
bool tainted
Definition heap.h:20
char * memset()
Here is the call graph for this function:

◆ kissat_release_heap()

void kissat_release_heap ( struct kissat * solver,
heap * heap )

Definition at line 10 of file heap.c.

10 {
14 memset (heap, 0, sizeof *heap);
15}
#define RELEASE_STACK(S)
Definition stack.h:71
#define DEALLOC(P, N)
unsigneds stack
Definition heap.h:23
unsigned size
Definition heap.h:22
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_rescale_heap()

void kissat_rescale_heap ( struct kissat * solver,
heap * heap,
double factor )

Definition at line 69 of file heap.c.

69 {
70 LOG ("rescaling scores on heap with factor %g", factor);
71 double *score = heap->score;
72 for (unsigned i = 0; i < heap->vars; i++)
73 score[i] *= factor;
74#ifndef KISSAT_NDEBUG
76#endif
77#ifndef LOGGING
78 (void) solver;
79#endif
80}
#define kissat_check_heap(...)
Definition heap.h:83
Here is the caller graph for this function:

◆ kissat_resize_heap()

void kissat_resize_heap ( struct kissat * solver,
heap * heap,
unsigned size )

Definition at line 46 of file heap.c.

46 {
47 const unsigned old_size = heap->size;
48 if (old_size >= new_size)
49 return;
50 LOG ("resizing %s heap from %u to %u",
51 (heap->tainted ? "tainted" : "untainted"), old_size, new_size);
52
53 heap->pos = (unsigned*)kissat_nrealloc (solver, heap->pos, old_size, new_size,
54 sizeof (unsigned));
55 if (heap->tainted) {
56 heap->score = (double*)kissat_nrealloc (solver, heap->score, old_size, new_size,
57 sizeof (double));
58 } else {
59 if (old_size)
60 DEALLOC (heap->score, old_size);
61 heap->score = (double*)kissat_calloc (solver, new_size, sizeof (double));
62 }
63 heap->size = new_size;
64#ifdef CHECK_HEAP
66#endif
67}
void * kissat_calloc(kissat *solver, size_t n, size_t size)
Definition allocate.c:97
void * kissat_nrealloc(kissat *solver, void *p, size_t o, size_t n, size_t size)
Definition allocate.c:151
Here is the call graph for this function:
Here is the caller graph for this function: