Skip to content

Commit

Permalink
Added extra user customization capabilities to partitioning and optim…
Browse files Browse the repository at this point in the history
…ization commands
  • Loading branch information
maustin8 committed Aug 12, 2019
1 parent 2725fad commit a0c20cb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
9 changes: 5 additions & 4 deletions core/lsoracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ namespace alice{
filename.erase(filename.end() - 2, filename.end());
aig._storage->net_name = filename;

std::cout << "Verilog file written\n";
}

}
Expand Down Expand Up @@ -1256,7 +1255,7 @@ namespace alice{
: command( env, "Classify partitions and perform corresponding optimization on stored AIG network (result is MIG network)" ){

opts.add_option( "--nn_model,-c",nn_model, "Trained neural network model for classification" );
opts.add_option( "--out,-o", out_file, "Verilog output" )->required();
opts.add_option( "--out,-o", out_file, "Verilog output" );
add_flag("--brute,-b", "Uses a brute force approach instead of classification");
add_flag("--aig,-a", "Perform only AIG optimization on all partitions");
add_flag("--mig,-m", "Perform only MIG optimization on all partitions");
Expand Down Expand Up @@ -1407,7 +1406,9 @@ namespace alice{
std::cout << "Full Optimization: " << duration.count() << "ms\n";
std::cout << "Finished optimization\n";
store<mockturtle::mig_network>().extend() = ntk_mig;
mockturtle::write_verilog(ntk_mig, out_file);

if(out_file != "")
mockturtle::write_verilog(ntk_mig, out_file);

}
else{
Expand Down Expand Up @@ -2447,4 +2448,4 @@ namespace alice{
} // namespace alice

/* Main method for the Alice shell (with prefix) */
ALICE_MAIN( lsoracle )
ALICE_MAIN( lsoracle )
24 changes: 20 additions & 4 deletions lib/oracle/include/oracle/commands/partitioning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace alice
: command( env, "Partitionins current network using k-means hypergraph partitioner" ) {

opts.add_option( "--num,num", num_partitions, "Number of desired partitions" )->required();
opts.add_option( "--config_direc,-c", config_direc, "Path to the configuration file for KaHyPar (../../core/test.ini is default)" );
add_flag("--mig,-m", "Partitions stored MIG network (AIG network is default)");
}

Expand All @@ -36,8 +37,15 @@ namespace alice
if(!store<mockturtle::mig_network>().empty()){
std::cout << "Partitioning stored MIG network\n";
auto ntk = store<mockturtle::mig_network>().current();
oracle::partition_manager<mockturtle::mig_network> partitions(ntk, num_partitions);
store<oracle::partition_manager<mockturtle::mig_network>>().extend() = partitions;
if(config_direc != ""){
oracle::partition_manager<mockturtle::mig_network> partitions(ntk, num_partitions, config_direc);
store<oracle::partition_manager<mockturtle::mig_network>>().extend() = partitions;
}
else{
oracle::partition_manager<mockturtle::mig_network> partitions(ntk, num_partitions);
store<oracle::partition_manager<mockturtle::mig_network>>().extend() = partitions;
}

}
else{
std::cout << "MIG network not stored\n";
Expand All @@ -47,8 +55,15 @@ namespace alice
if(!store<mockturtle::aig_network>().empty()){
std::cout << "Partitioning stored AIG network\n";
auto ntk = store<mockturtle::aig_network>().current();
oracle::partition_manager<mockturtle::aig_network> partitions(ntk, num_partitions);
store<oracle::partition_manager<mockturtle::aig_network>>().extend() = partitions;
if(config_direc != ""){
oracle::partition_manager<mockturtle::aig_network> partitions(ntk, num_partitions, config_direc);
store<oracle::partition_manager<mockturtle::aig_network>>().extend() = partitions;
}
else{
oracle::partition_manager<mockturtle::aig_network> partitions(ntk, num_partitions);
store<oracle::partition_manager<mockturtle::aig_network>>().extend() = partitions;
}

}
else{
std::cout << "AIG network not stored\n";
Expand All @@ -57,6 +72,7 @@ namespace alice
}
private:
int num_partitions{};
std::string config_direc = "";
};

ALICE_ADD_COMMAND(partitioning, "Partitioning");
Expand Down
5 changes: 3 additions & 2 deletions lib/oracle/include/oracle/partitioning/partition_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace oracle
partitionOutputs = outputs;
}

partition_manager( Ntk const& ntk, int part_num ) : Ntk( ntk )
partition_manager( Ntk const& ntk, int part_num, std::string config_direc="../../core/" ) : Ntk( ntk )
{

static_assert( mockturtle::is_network_type_v<Ntk>, "Ntk is not a network type" );
Expand Down Expand Up @@ -208,7 +208,8 @@ namespace oracle
******************/
//configures kahypar
kahypar_context_t* context = kahypar_context_new();
kahypar_configure_context_from_file(context, "../../core/test.ini");
config_direc = config_direc + "test.ini";
kahypar_configure_context_from_file(context, config_direc.c_str());

//set number of hyperedges and vertices. These variables are defined by the hyperG command
const kahypar_hyperedge_id_t num_hyperedges = kahyp_num_hyperedges;
Expand Down

0 comments on commit a0c20cb

Please sign in to comment.