src/mapper.cc
// map kernel's circuit, main mapper entry once per kernel
map kernel's circuit, main mapper entry once per kernel
map kernel ' s circuit main mapper entry once per kernel
void Mapper::Map(ql::quantum_kernel& kernel)
{
    COUT("Mapping kernel " << kernel.name << " [START]");
    DOUT("... kernel original virtual number of qubits=" << kernel.qubit_count);
    nc = kernel.creg_count;     
    kernelp = NULL;             
    Virt2Real   v2r;            
    v2r.Init(nq);               
    v2r.DPRINT("After initialization");
    v2r.Export(v2r_in);  
    v2r.Export(rs_in);   
    std::string initialplaceopt = ql::options::get("initialplace");
    if("no" != initialplaceopt)
    {
#ifdef INITIALPLACE
        std::string initialplace2qhorizonopt = ql::options::get("initialplace2qhorizon");
        DOUT("InitialPlace: kernel=" << kernel.name << " initialplace=" << initialplaceopt << " initialplace2qhorizon=" << initialplace2qhorizonopt << " [START]");
        InitialPlace    ip;             
        ipr_t           ipok;           
        double          iptimetaken;      
        ip.Init(&grid, platformp);
        ip.Place(kernel.c, v2r, ipok, iptimetaken, initialplaceopt); 
        DOUT("InitialPlace: kernel=" << kernel.name << " initialplace=" << initialplaceopt << " initialplace2qhorizon=" << initialplace2qhorizonopt << " result=" << ip.ipr2string(ipok) << " iptimetaken=" << iptimetaken << " seconds [DONE]");
#else 
        DOUT("InitialPlace support disabled during OpenQL build [DONE]");
        WOUT("InitialPlace support disabled during OpenQL build [DONE]");
#endif 
    }
    v2r.DPRINT("After InitialPlace");
    v2r.Export(v2r_ip);  
    v2r.Export(rs_ip);   
    MapCircuit(kernel, v2r);        
    v2r.DPRINT("After heuristics");
    MakePrimitives(kernel);         
    kernel.qubit_count = nq;        
    v2r.Export(v2r_out);     
    v2r.Export(rs_out);      
    COUT("Mapping kernel " << kernel.name << " [DONE]");
}
void Mapper :: Map ( ql :: quantum_kernel & kernel ) { COUT ( " " << kernel . name << " " ) ; DOUT ( " " << kernel . qubit_count ) ; nc = kernel . creg_count ; kernelp = NULL ; Virt2Real v2r ; v2r . Init ( nq ) ; v2r . DPRINT ( " " ) ; v2r . Export ( v2r_in ) ; v2r . Export ( rs_in ) ; std :: string initialplaceopt = ql :: options :: get ( " " ) ; if ( " " != initialplaceopt ) { #ifdef INITIALPLACE std :: string initialplace2qhorizonopt = ql :: options :: get ( " " ) ; DOUT ( " " << kernel . name << " " << initialplaceopt << " " << initialplace2qhorizonopt << " " ) ; InitialPlace ip ; ipr_t ipok ; double iptimetaken ; ip . Init ( & grid , platformp ) ; ip . Place ( kernel . c , v2r , ipok , iptimetaken , initialplaceopt ) ; DOUT ( " " << kernel . name << " " << initialplaceopt << " " << initialplace2qhorizonopt << " " << ip . ipr2string ( ipok ) << " " << iptimetaken << " " ) ; #else DOUT ( " " ) ; WOUT ( " " ) ; #endif } v2r . DPRINT ( " " ) ; v2r . Export ( v2r_ip ) ; v2r . Export ( rs_ip ) ; MapCircuit ( kernel , v2r ) ; v2r . DPRINT ( " " ) ; MakePrimitives ( kernel ) ; kernel . qubit_count = nq ; v2r . Export ( v2r_out ) ; v2r . Export ( rs_out ) ; COUT ( " " << kernel . name << " " ) ; }
map kernel's circuit, main mapper entry once per kernel
map kernel ' s circuit main mapper entry once per kernel
// in absence of platform creg_count, take it from kernel, i.e. from OpenQL program // no new_gates until kernel.c has been copied // current mapping while mapping this kernel // unify all incoming v2rs into v2r to compute kernel input mapping; // but until inter-kernel mapping is implemented, take program initial mapping for it // v2r now contains program initial mapping // from v2r to caller for reporting // from v2r to caller for reporting // initial placer facility // one of several ip result possibilities // time solving the initial placement took, in seconds // compute mapping (in v2r) using ip model, may fail // ifdef INITIALPLACE // ifdef INITIALPLACE // from v2r to caller for reporting // from v2r to caller for reporting // updates kernel.c with swaps, maps all gates, updates v2r map // decompose to primitives as specified in the config file // bluntly copy nq (==#real qubits), so that all kernels get the same qubit_count // from v2r to caller for reporting // from v2r to caller for reporting