ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
eSLIM.cpp File Reference
#include "utils.hpp"
#include "eSLIMMan.hpp"
#include "relationGeneration.hpp"
#include "selectionStrategy.hpp"
#include "misc/util/abc_namespaces.h"
#include "eSLIM.h"
Include dependency graph for eSLIM.cpp:

Go to the source code of this file.

Functions

ABC_NAMESPACE_HEADER_START Gia_Man_tGia_ManDeepSyn (Gia_Man_t *pGia, int nIters, int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose)
 
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_IMPL_START eSLIM::eSLIMConfig getCfg (const eSLIM_ParamStruct *params)
 
void seteSLIMParams (eSLIM_ParamStruct *params)
 
Gia_Man_tselectApproach (Gia_Man_t *pGia, eSLIM::eSLIMConfig params, eSLIM::eSLIMLog &log, int approach, bool allow_forbidden_pairs)
 
Gia_Man_trunInprocessing (Gia_Man_t *pGia, const eSLIM_ParamStruct *params, unsigned int it)
 
void printSetting (const eSLIM_ParamStruct *params)
 
Gia_Man_tapplyeSLIM (Gia_Man_t *pGia, const eSLIM_ParamStruct *params)
 

Function Documentation

◆ applyeSLIM()

Gia_Man_t * applyeSLIM ( Gia_Man_t * pGia,
const eSLIM_ParamStruct * params )

Definition at line 134 of file eSLIM.cpp.

134 {
136 config.verbosity_level = params->verbosity_level;
137
138 int eSLIM_reductions = 0;
139 int deepsyn_reductions = 0;
140
141 Gia_Man_t * pThis = Gia_ManDup(pGia);
142 eSLIM::eSLIMLog log(params->subcircuit_size_bound);
143 int initial_size = Gia_ManAndNum(pThis);
144 if (params->verbosity_level > 0) {
145 printSetting(params);
146 std::cout << "Initial size: " << initial_size << "\n";
147 }
148 for (unsigned int i = 0; i < params->nruns; i++) {
149 if (config.fix_seed) {
150 config.seed = params->seed + i;
151 }
152 int size_iteration_start = Gia_ManAndNum(pThis);
153 if (params->verbosity_level > 0) {
154 std::cout << "Start eslim run " << i + 1 << "\n";
155 }
156 pThis = selectApproach(pThis, config, log, params->mode, params->forbidden_pairs);
157 int size_eslim = Gia_ManAndNum(pThis);
158 eSLIM_reductions += size_iteration_start - size_eslim;
159
160 if (params->apply_inprocessing) {
161 if (params->verbosity_level > 0) {
162 std::cout << "Start inprocessing run " << i + 1 << "\n";
163 }
164 pThis = runInprocessing(pThis, params, i);
165 if (params->verbosity_level > 0) {
166 std::cout << "Inprocessing: Initial size: " << size_eslim << " final size: " << Gia_ManAndNum(pThis) << "\n";
167 }
168 deepsyn_reductions += size_eslim - Gia_ManAndNum(pThis);
169 }
170 }
171 if (params->verbosity_level > 0) {
172 int final_size = Gia_ManAndNum(pThis);
173 std::cout << "Final size: " << final_size << "\n";
174 int total_reductions = eSLIM_reductions + deepsyn_reductions;
175 double reduction_ratio = 100 * static_cast<double>(total_reductions) / initial_size;
176 printf("Total reduction: %d (%.2f %%)\n", total_reductions, reduction_ratio);
177 if (params->apply_inprocessing) {
178 std::cout << "#Gates reduced by eSLIM: " << eSLIM_reductions << " ";
179 std::cout << "#Gates reduced by deepsyn: " << deepsyn_reductions << "\n";
180 }
181 }
182
183 if (params->verbosity_level > 1) {
184 std::cout << "Total #iterations: " << log.iteration_count << "\n";
185 std::cout << "Total relation generation time (s): " << log.relation_generation_time << "\n";
186 std::cout << "Total synthesis time (s): " << log.synthesis_time << "\n";
187 std::cout << "#Iterations with forbidden pairs: " << log.subcircuits_with_forbidden_pairs << "\n";
188 }
189 if (params->verbosity_level > 2) {
190 for (int i = 2; i < log.nof_analyzed_circuits_per_size.size(); i++) {
191 int replaced = log.nof_replaced_circuits_per_size.size() > i ? log.nof_replaced_circuits_per_size[i] : 0;
192 int reduced = log.nof_reduced_circuits_per_size.size() > i ? log.nof_reduced_circuits_per_size[i] : 0;
193 std::cout << "#gates: " << i << " - #analysed: " << log.nof_analyzed_circuits_per_size[i] << " - #replaced: " << replaced << " - #reduced: " << reduced << "\n";
194 }
195 if (params->mode == 0) {
196 for (int i = 0; i < log.nof_sat_calls_per_size.size(); i++) {
197 if (log.nof_sat_calls_per_size[i] == 0) {
198 std::cout << "#gates: " << i << " - avg. sat time: -\n";
199 } else {
200 std::cout << "#gates: " << i << " - avg. sat time: " << static_cast<double>(log.cummulative_sat_runtimes_per_size[i]) / (1000 * log.nof_sat_calls_per_size[i]) << " sec\n";
201 }
202 }
203 for (int i = 0; i < log.nof_unsat_calls_per_size.size(); i++) {
204 if (log.nof_unsat_calls_per_size[i] == 0) {
205 std::cout << "#gates: " << i << " - avg. unsat time: -\n";
206 } else {
207 std::cout << "#gates: " << i << " - avg. unsat time: " << static_cast<double>(log.cummulative_unsat_runtimes_per_size[i]) / (1000* log.nof_unsat_calls_per_size[i]) << " sec\n";
208 }
209 }
210 }
211 }
212 return pThis;
213}
struct config_s config
void printSetting(const eSLIM_ParamStruct *params)
Definition eSLIM.cpp:113
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_IMPL_START eSLIM::eSLIMConfig getCfg(const eSLIM_ParamStruct *params)
Definition eSLIM.cpp:36
Gia_Man_t * runInprocessing(Gia_Man_t *pGia, const eSLIM_ParamStruct *params, unsigned int it)
Definition eSLIM.cpp:102
Gia_Man_t * selectApproach(Gia_Man_t *pGia, eSLIM::eSLIMConfig params, eSLIM::eSLIMLog &log, int approach, bool allow_forbidden_pairs)
Definition eSLIM.cpp:75
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Here is the call graph for this function:

◆ getCfg()

Definition at line 36 of file eSLIM.cpp.

36 {
38 config.extended_normality_processing = params->extended_normality_processing;
39 config.apply_strash = params->apply_strash;
40 config.fill_subcircuits = params->fill_subcircuits;
41 config.fix_seed = params->fix_seed;
42 config.trial_limit_active = params->trial_limit_active;
43 config.timeout = params->timeout;
44 config.iterations = params->iterations;
45 config.subcircuit_size_bound = params->subcircuit_size_bound;
46 config.strash_intervall = params->strash_intervall;
47 config.nselection_trials = params->nselection_trials;
48 config.seed = params->seed;
49 config.verbosity_level = params->verbosity_level;
50 config.expansion_probability = params->expansion_probability;
51 return config;
52}
Here is the caller graph for this function:

◆ Gia_ManDeepSyn()

ABC_NAMESPACE_HEADER_START Gia_Man_t * Gia_ManDeepSyn ( Gia_Man_t * pGia,
int nIters,
int nNoImpr,
int TimeOut,
int nAnds,
int Seed,
int fUseTwo,
int fVerbose )

CFile****************************************************************

FileName [eSLIM.cpp]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Using Exact Synthesis with the SAT-based Local Improvement Method (eSLIM).]

Synopsis [Interface to the eSLIM package.]

Author [Franz-Xaver Reichl]

Affiliation [University of Freiburg]

Date [Ver. 1.0. Started - March 2025.]

Revision [

Id
eSLIM.cpp,v 1.00 2025/03/17 00:00:00 Exp

]

Definition at line 142 of file giaDeep.c.

143{
144 Gia_Man_t * pInit = Gia_ManDup(pGia);
145 Gia_Man_t * pBest = Gia_ManDup(pGia);
146 Gia_Man_t * pThis;
147 int i;
148 for ( i = 0; i < nIters; i++ )
149 {
151 pThis = Gia_ManDeepSynOne( nNoImpr, TimeOut, nAnds, Seed+i, fUseTwo, fVerbose );
152 if ( Gia_ManAndNum(pBest) > Gia_ManAndNum(pThis) )
153 {
154 Gia_ManStop( pBest );
155 pBest = pThis;
156 }
157 else
158 Gia_ManStop( pThis );
159
160 }
161 Gia_ManStop( pInit );
162 return pBest;
163}
void Abc_FrameUpdateGia(Abc_Frame_t *pAbc, Gia_Man_t *pNew)
Definition abc.c:824
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_ManDeepSynOne(int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose)
DECLARATIONS ///.
Definition giaDeep.c:46
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printSetting()

void printSetting ( const eSLIM_ParamStruct * params)

Definition at line 113 of file eSLIM.cpp.

113 {
114 std::cout << "Apply eSLIM (timeout: " << params->timeout << ") ";
115 if (params->apply_inprocessing) {
116 std::cout << "+ deepsyn (timeout: " << params->timeout_inprocessing << ") ";
117 }
118 std::cout << params->nruns << " times.\n";
119 if (params->iterations > 0) {
120 std::cout << "Stop eSLIM runs after " << params->iterations << " iterations.\n";
121 }
122 std::cout << "Consider subcircuits with up to " << params->subcircuit_size_bound << " gates.\n";
123 printf("When expanding subcircuits, select gates with a probability of %.2f %%.\n", 100 * params->expansion_probability);
124 if (params->forbidden_pairs) {
125 std::cout << "Consider subcircuits containing gates, which are connected outside of the subcircuit.\n";
126 }
127 if (params->mode == 0) {
128 std::cout << "Use an incremental SAT encoding for exact synthesis and the SAT solver CaDiCaL.\n";
129 } else {
130 std::cout << "Use a one-shot SAT encoding for exact synthesis and the SAT solver Kissat.\n";
131 }
132}
Here is the caller graph for this function:

◆ runInprocessing()

Gia_Man_t * runInprocessing ( Gia_Man_t * pGia,
const eSLIM_ParamStruct * params,
unsigned int it )

Definition at line 102 of file eSLIM.cpp.

102 {
103 Gia_Man_t * tmp = Gia_ManDeepSyn( pGia, 1, ABC_INFINITY, params->timeout_inprocessing, 0, params->seed + it, 0, 0);
104 if ( Gia_ManAndNum(pGia) > Gia_ManAndNum(tmp) ) {
105 Gia_ManStop( pGia );
106 pGia = tmp;
107 } else {
108 Gia_ManStop( tmp );
109 }
110 return pGia;
111}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
ABC_NAMESPACE_HEADER_START Gia_Man_t * Gia_ManDeepSyn(Gia_Man_t *pGia, int nIters, int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose)
Definition giaDeep.c:142
Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectApproach()

Gia_Man_t * selectApproach ( Gia_Man_t * pGia,
eSLIM::eSLIMConfig params,
eSLIM::eSLIMLog & log,
int approach,
bool allow_forbidden_pairs )

Definition at line 75 of file eSLIM.cpp.

75 {
76 switch (approach) {
77 case 0 :
78 if (allow_forbidden_pairs) {
80 } else {
82 };
83 case 1:
84 if (allow_forbidden_pairs) {
86 } else {
88 };
89 case 2:
90 if (allow_forbidden_pairs) {
92 } else {
94 };
95 default:
96 std::cerr << "eSLIM -- Invalid mode given\n";
97 assert (false && "Invalid approach selected");
98 return nullptr;
99 }
100}
static Gia_Man_t * applyeSLIM(Gia_Man_t *p, const eSLIMConfig &cfg, eSLIMLog &log)
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ seteSLIMParams()

void seteSLIMParams ( eSLIM_ParamStruct * params)

Definition at line 54 of file eSLIM.cpp.

54 {
55 params->forbidden_pairs = 1;
56 params->extended_normality_processing = 0;
57 params->fill_subcircuits = 0;
58 params->apply_strash = 1;
59 params->fix_seed = 0;
60 params->trial_limit_active = 1;
61 params->apply_inprocessing = 1;
62 params->timeout = 1620;
63 params->timeout_inprocessing = 180;
64 params->iterations = 0;
65 params->subcircuit_size_bound = 6;
66 params->strash_intervall = 100;
67 params->nselection_trials = 100;
68 params->nruns = 1;
69 params->mode = 0;
70 params->seed = 0;
71 params->verbosity_level = 1;
72 params->expansion_probability = 0.4;
73}