コード例 #1
0
ファイル: pdb2top.c プロジェクト: chenleo/gromacs453pf
void write_top(FILE *out, char *pr,char *molname,
               t_atoms *at,gmx_bool bRTPresname,
               int bts[],t_params plist[],t_excls excls[],
               gpp_atomtype_t atype,int *cgnr, int nrexcl)
     /* NOTE: nrexcl is not the size of *excl! */
{
  if (at && atype && cgnr) {
    fprintf(out,"[ %s ]\n",dir2str(d_moleculetype));
    fprintf(out,"; %-15s %5s\n","Name","nrexcl");
    fprintf(out,"%-15s %5d\n\n",molname?molname:"Protein",nrexcl);
    
    print_atoms(out, atype, at, cgnr, bRTPresname);
    print_bondeds(out,at->nr,d_bonds,      F_BONDS,    bts[ebtsBONDS], plist);
    print_bondeds(out,at->nr,d_constraints,F_CONSTR,   0,              plist);
    print_bondeds(out,at->nr,d_constraints,F_CONSTRNC, 0,              plist);
    print_bondeds(out,at->nr,d_pairs,      F_LJ14,     0,              plist);
    print_excl(out,at->nr,excls);
    print_bondeds(out,at->nr,d_angles,     F_ANGLES,   bts[ebtsANGLES],plist);
    print_bondeds(out,at->nr,d_dihedrals,  F_PDIHS,    bts[ebtsPDIHS], plist);
    print_bondeds(out,at->nr,d_dihedrals,  F_IDIHS,    bts[ebtsIDIHS], plist);
    print_bondeds(out,at->nr,d_cmap,       F_CMAP,     bts[ebtsCMAP],  plist);
    print_bondeds(out,at->nr,d_polarization,F_POLARIZATION,   0,       plist);
    print_bondeds(out,at->nr,d_thole_polarization,F_THOLE_POL,0,       plist);
    print_bondeds(out,at->nr,d_vsites2,    F_VSITE2,   0,              plist);
    print_bondeds(out,at->nr,d_vsites3,    F_VSITE3,   0,              plist);
    print_bondeds(out,at->nr,d_vsites3,    F_VSITE3FD, 0,              plist);
    print_bondeds(out,at->nr,d_vsites3,    F_VSITE3FAD,0,              plist);
    print_bondeds(out,at->nr,d_vsites3,    F_VSITE3OUT,0,              plist);
    print_bondeds(out,at->nr,d_vsites4,    F_VSITE4FD, 0,              plist);
    print_bondeds(out,at->nr,d_vsites4,    F_VSITE4FDN, 0,             plist);
    
    if (pr)
      print_top_posre(out,pr);
  }
}
コード例 #2
0
void print_excl(FILE *out, int natoms, t_excls excls[])
{
    atom_id     i;
    gmx_bool    have_excl;
    int         j;

    have_excl = FALSE;
    for (i = 0; i < natoms && !have_excl; i++)
    {
        have_excl = (excls[i].nr > 0);
    }

    if (have_excl)
    {
        fprintf (out, "[ %s ]\n", dir2str(d_exclusions));
        fprintf (out, "; %4s    %s\n", "i", "excluded from i");
        for (i = 0; i < natoms; i++)
        {
            if (excls[i].nr > 0)
            {
                fprintf (out, "%6d ", i+1);
                for (j = 0; j < excls[i].nr; j++)
                {
                    fprintf (out, " %5d", excls[i].e[j]+1);
                }
                fprintf (out, "\n");
            }
        }
        fprintf (out, "\n");
        fflush(out);
    }
}
コード例 #3
0
void
print_ioctlent(const char *info, const char *name,
	       u16 dir, u16 type, u16 nr, u16 size)
{
	unsigned int type_nr =
		((unsigned) type << _IOC_TYPESHIFT) |
		((unsigned) nr << _IOC_NRSHIFT);

	if (dir & ~_IOC_DIRMASK)
		fprintf(stderr,
			"print_ioctlents: WARNING: dir 0x%02x is out of mask 0x%02x in %s\n",
			dir, _IOC_DIRMASK, name);
	if (type & ~_IOC_TYPEMASK)
		fprintf(stderr,
			"print_ioctlents: WARNING: type 0x%02x is out of mask 0x%02x in %s\n",
			type, _IOC_TYPEMASK, name);
	if (nr & ~_IOC_NRMASK)
		fprintf(stderr,
			"print_ioctlents: WARNING: nr 0x%02x is out of mask 0x%02x in %s\n",
			nr, _IOC_NRMASK, name);
	if (size & ~_IOC_SIZEMASK)
		fprintf(stderr,
			"print_ioctlents: WARNING: size 0x%02x is out of mask 0x%02x in %s\n",
			size, _IOC_SIZEMASK, name);

	printf("{ \"%s\", \"%s\", %s, 0x%04x, 0x%02x },\n",
		info, name, dir2str(name, dir), type_nr, size);
}
コード例 #4
0
ファイル: pdb2top.c プロジェクト: chenleo/gromacs453pf
void print_top_mols(FILE *out,
                    const char *title, const char *ffdir, const char *water,
                    int nincl, char **incls, int nmol, t_mols *mols)
{
  int  i;
  char *incl;

  if (nincl>0) {
    fprintf(out,"; Include chain topologies\n");
    for (i=0; (i<nincl); i++) {
        incl = strrchr(incls[i],DIR_SEPARATOR);
        if (incl == NULL) {
            incl = incls[i];
        } else {
            /* Remove the path from the include name */
            incl = incl + 1;
        }
      fprintf(out,"#include \"%s\"\n",incl);
    }
    fprintf(out,"\n");
  }

    if (water)
    {
      print_top_water(out,ffdir,water);
    }
    print_top_system(out, title);
  
  if (nmol) {
    fprintf(out,"[ %s ]\n",dir2str(d_molecules));
    fprintf(out,"; %-15s %5s\n","Compound","#mols");
    for (i=0; (i<nmol); i++)
      fprintf(out,"%-15s %5d\n",mols[i].name,mols[i].nr);
  }
}
コード例 #5
0
ファイル: repo_rpmmd.c プロジェクト: openSUSE/sat-solver
static void
commit_diskusage (struct parsedata *pd, unsigned handle)
{
  unsigned i;
  Dirpool *dp = &pd->data->dirpool;
  /* Now sort in dirid order.  This ensures that parents come before
     their children.  */
  if (pd->ndirs > 1)
    sat_sort(pd->dirs, pd->ndirs, sizeof (pd->dirs[0]), id3_cmp, 0);
  /* Substract leaf numbers from all parents to make the numbers
     non-cumulative.  This must be done post-order (i.e. all leafs
     adjusted before parents).  We ensure this by starting at the end of
     the array moving to the start, hence seeing leafs before parents.  */
  for (i = pd->ndirs; i--;)
    {
      unsigned p = dirpool_parent(dp, pd->dirs[i][0]);
      unsigned j = i;
      for (; p; p = dirpool_parent(dp, p))
        {
          for (; j--;)
	    if (pd->dirs[j][0] == p)
	      break;
	  if (j < pd->ndirs)
	    {
	      if (pd->dirs[j][1] < pd->dirs[i][1])
	        pd->dirs[j][1] = 0;
	      else
	        pd->dirs[j][1] -= pd->dirs[i][1];
	      if (pd->dirs[j][2] < pd->dirs[i][2])
	        pd->dirs[j][2] = 0;
	      else
	        pd->dirs[j][2] -= pd->dirs[i][2];
	    }
	  else
	    /* Haven't found this parent in the list, look further if
	       we maybe find the parents parent.  */
	    j = i;
	}
    }
#if 0
  char sbuf[1024];
  char *buf = sbuf;
  unsigned slen = sizeof (sbuf);
  for (i = 0; i < pd->ndirs; i++)
    {
      dir2str (attr, pd->dirs[i][0], &buf, &slen);
      fprintf (stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
    }
  if (buf != sbuf)
    free (buf);
#endif
  for (i = 0; i < pd->ndirs; i++)
    if (pd->dirs[i][1] || pd->dirs[i][2])
      {
	repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
      }
  pd->ndirs = 0;
}
コード例 #6
0
ファイル: gpp_atomtype.cpp プロジェクト: tanigawa/gromacs
void print_at (FILE * out, gpp_atomtype_t ga)
{
    int         i;
    t_atom     *atom = ga->atom;
    t_param    *nb   = ga->nb;

    fprintf (out, "[ %s ]\n", dir2str(d_atomtypes));
    fprintf (out, "; %6s  %8s  %8s  %8s  %12s  %12s\n",
             "type", "mass", "charge", "particle", "c6", "c12");
    for (i = 0; (i < ga->nr); i++)
    {
        fprintf(out, "%8s  %8.3f  %8.3f  %8s  %12e  %12e\n",
                *(ga->atomname[i]), atom[i].m, atom[i].q, "A",
                nb[i].c0(), nb[i].c1());
    }

    fprintf (out, "\n");
}
コード例 #7
0
ファイル: topdirs.c プロジェクト: pdalcin/Gromacs_GA
directive str2dir (char *dstr)
{
  directive d;
  char buf[STRLEN],*ptr;
  
  /* Hack to be able to read old topologies */
  if (strncasecmp_min(dstr,"dummies",7) == 0) {
    sprintf(buf,"virtual_sites%s",dstr+7);
    ptr = buf;
  } else {
    ptr = dstr;
  }
  
  for (d=(directive)0; (d<d_maxdir); d++)
    if (strcasecmp_min(ptr,dir2str(d)) == 0)
      return d;

  return d_invalid;
}
コード例 #8
0
void print_atoms(FILE *out, gpp_atomtype_t atype, t_atoms *at, int *cgnr,
                 gmx_bool bRTPresname)
{
    int         i, ri;
    int         tpA, tpB;
    const char *as;
    char       *tpnmA, *tpnmB;
    double      qres, qtot;

    as = dir2str(d_atoms);
    fprintf(out, "[ %s ]\n", as);
    fprintf(out, "; %4s %10s %6s %7s%6s %6s %10s %10s %6s %10s %10s\n",
            "nr", "type", "resnr", "residue", "atom", "cgnr", "charge", "mass", "typeB", "chargeB", "massB");

    qtot  = 0;

    if (debug)
    {
        fprintf(debug, "This molecule has %d atoms and %d residues\n",
                at->nr, at->nres);
    }

    if (at->nres)
    {
        /* if the information is present... */
        for (i = 0; (i < at->nr); i++)
        {
            ri = at->atom[i].resind;
            if ((i == 0 || ri != at->atom[i-1].resind) &&
                at->resinfo[ri].rtp != NULL)
            {
                qres = get_residue_charge(at, i);
                fprintf(out, "; residue %3d %-3s rtp %-4s q ",
                        at->resinfo[ri].nr,
                        *at->resinfo[ri].name,
                        *at->resinfo[ri].rtp);
                if (fabs(qres) < 0.001)
                {
                    fprintf(out, " %s", "0.0");
                }
                else
                {
                    fprintf(out, "%+3.1f", qres);
                }
                fprintf(out, "\n");
            }
            tpA = at->atom[i].type;
            if ((tpnmA = get_atomtype_name(tpA, atype)) == NULL)
            {
                gmx_fatal(FARGS, "tpA = %d, i= %d in print_atoms", tpA, i);
            }

            fprintf(out, "%6d %10s %6d%c %5s %6s %6d %10g %10g",
                    i+1, tpnmA,
                    at->resinfo[ri].nr,
                    at->resinfo[ri].ic,
                    bRTPresname ?
                    *(at->resinfo[at->atom[i].resind].rtp) :
                    *(at->resinfo[at->atom[i].resind].name),
                    *(at->atomname[i]), cgnr[i],
                    at->atom[i].q, at->atom[i].m);
            if (PERTURBED(at->atom[i]))
            {
                tpB = at->atom[i].typeB;
                if ((tpnmB = get_atomtype_name(tpB, atype)) == NULL)
                {
                    gmx_fatal(FARGS, "tpB = %d, i= %d in print_atoms", tpB, i);
                }
                fprintf(out, " %6s %10g %10g",
                        tpnmB, at->atom[i].qB, at->atom[i].mB);
            }
            qtot += (double)at->atom[i].q;
            if (fabs(qtot) < 4*GMX_REAL_EPS)
            {
                qtot = 0;
            }
            fprintf(out, "   ; qtot %.4g\n", qtot);
        }
    }
    fprintf(out, "\n");
    fflush(out);
}
コード例 #9
0
void print_bt(FILE *out, directive d, gpp_atomtype_t at,
              int ftype, int fsubtype, t_params plist[],
              gmx_bool bFullDih)
{
    /* This dihp is a DIRTY patch because the dih-types do not use
     * all four atoms to determine the type.
     */
    const int    dihp[2][2] = { { 1, 2 }, { 0, 3 } };
    t_params    *bt;
    int          i, j, f, nral, nrfp;
    gmx_bool     bDih = FALSE, bSwapParity;

    bt = &(plist[ftype]);

    if (!bt->nr)
    {
        return;
    }

    f = 0;
    switch (ftype)
    {
        case F_G96ANGLES:
            f = 1;
            break;
        case F_G96BONDS:
            f = 1;
            break;
        case F_MORSE:
            f = 2;
            break;
        case F_CUBICBONDS:
            f = 3;
            break;
        case F_CONNBONDS:
            f = 4;
            break;
        case F_HARMONIC:
            f = 5;
            break;
        case F_CROSS_BOND_ANGLES:
            f = 2;
            break;
        case F_CROSS_BOND_BONDS:
            f = 3;
            break;
        case F_UREY_BRADLEY:
            f = 4;
            break;
        case F_PDIHS:
        case F_RBDIHS:
        case F_FOURDIHS:
            bDih = TRUE;
            break;
        case F_IDIHS:
            f    = 1;
            bDih = TRUE;
            break;
        case F_CONSTRNC:
            f = 1;
            break;
        case F_VSITE3FD:
            f = 1;
            break;
        case F_VSITE3FAD:
            f = 2;
            break;
        case F_VSITE3OUT:
            f = 3;
            break;
        case F_VSITE4FDN:
            f = 1;
            break;
        case F_CMAP:
            f = 1;
            break;

        default:
            bDih = FALSE;
    }
    if (bFullDih)
    {
        bDih = FALSE;
    }
    if (fsubtype)
    {
        f = fsubtype-1;
    }

    nral = NRAL(ftype);
    nrfp = NRFP(ftype);

    /* header */
    fprintf(out, "[ %s ]\n", dir2str(d));
    fprintf(out, "; ");
    if (!bDih)
    {
        fprintf (out, "%3s  %4s", "ai", "aj");
        for (j = 2; (j < nral); j++)
        {
            fprintf (out, "  %3c%c", 'a', 'i'+j);
        }
    }
    else
    {
        for (j = 0; (j < 2); j++)
        {
            fprintf (out, "%3c%c", 'a', 'i'+dihp[f][j]);
        }
    }

    fprintf (out, " funct");
    for (j = 0; (j < nrfp); j++)
    {
        fprintf (out, " %12c%1d", 'c', j);
    }
    fprintf (out, "\n");

    /* print bondtypes */
    for (i = 0; (i < bt->nr); i++)
    {
        bSwapParity = (bt->param[i].C0 == NOTSET) && (bt->param[i].C1 == -1);
        if (!bDih)
        {
            for (j = 0; (j < nral); j++)
            {
                fprintf (out, "%5s ", get_atomtype_name(bt->param[i].a[j], at));
            }
        }
        else
        {
            for (j = 0; (j < 2); j++)
            {
                fprintf (out, "%5s ", get_atomtype_name(bt->param[i].a[dihp[f][j]], at));
            }
        }
        fprintf (out, "%5d ", bSwapParity ? -f-1 : f+1);

        if (bt->param[i].s[0])
        {
            fprintf(out, "   %s", bt->param[i].s);
        }
        else
        {
            for (j = 0; (j < nrfp && (bt->param[i].c[j] != NOTSET)); j++)
            {
                fprintf (out, "%13.6e ", bt->param[i].c[j]);
            }
        }

        fprintf (out, "\n");
    }
    fprintf (out, "\n");
    fflush (out);
}
コード例 #10
0
ファイル: pdb2top.c プロジェクト: chenleo/gromacs453pf
static void print_top_system(FILE *out, const char *title)
{
  fprintf(out,"[ %s ]\n",dir2str(d_system));
  fprintf(out,"; Name\n");
  fprintf(out,"%s\n\n",title[0]?title:"Protein");
}
コード例 #11
0
ファイル: topdirs.c プロジェクト: pdalcin/Gromacs_GA
int ifunc_index(directive d,int type)
{
  switch (d) {
  case d_bondtypes:
  case d_bonds:
    if (type == 1)
      return F_BONDS;
    else if (type == 2)
      return F_G96BONDS;
    else if (type == 3)
      return F_MORSE;
    else if (type == 4)
      return F_CUBICBONDS;
    else if (type == 5)
      return F_CONNBONDS;
    else if (type == 6)
      return F_HARMONIC;
    else if (type == 7)
      return F_FENEBONDS;
    else if (type == 8)
      return F_TABBONDS;
    else if (type == 9)
      return F_TABBONDSNC;
    else
      gmx_fatal(FARGS,"Invalid bond type %d",type);
  case d_angles:
  case d_angletypes:
    if (type == 1)
      return F_ANGLES;
    else if (type == 2)
      return F_G96ANGLES;
    else if (type == 3)
      return F_CROSS_BOND_BONDS;
    else if (type == 4)
      return F_CROSS_BOND_ANGLES;
    else if (type == 5)
      return F_UREY_BRADLEY;
    else if (type == 6)
      return F_QUARTIC_ANGLES;
    else if (type == 8)
      return F_TABANGLES;
    else
      gmx_fatal(FARGS,"Invalid angle type %d",type);
  case d_pairs:
  case d_pairtypes:
    if (type == 1 || (d == d_pairtypes && type == 2))
      return F_LJ14;
    else if (type == 2)
      return F_LJC14_Q;
    else
      gmx_fatal(FARGS,"Invalid pairs type %d",type);
  case d_pairs_nb:
    return F_LJC_PAIRS_NB;
  case d_dihedrals:
  case d_dihedraltypes:
    switch (type) {
    case 1:
      return F_PDIHS;
    case 2:
      return F_IDIHS;
    case 3:
      return F_RBDIHS;
    case 4:  
      return F_PIDIHS;
    case 5:
      return F_FOURDIHS;
    case 8:
      return F_TABDIHS;
    case 9:
	  return F_PDIHS;  /* proper dihedrals where we allow multiple terms over single bond */
    default:
      gmx_fatal(FARGS,"Invalid dihedral type %d",type);
    }
    break;
  case d_nonbond_params:
    if (type == 1)
      return F_LJ;
    else
      return F_BHAM;
  case d_vsites2:
    return F_VSITE2;
  case d_vsites3:
    switch (type) {
    case 1:
      return F_VSITE3;
    case 2: 
      return F_VSITE3FD;
    case 3:
      return F_VSITE3FAD;
    case 4:
      return F_VSITE3OUT;  
    default:
      gmx_fatal(FARGS,"Invalid vsites3 type %d",type);
    }
  case d_vsites4:
      switch (type) {
          case 1:
              return F_VSITE4FD;
          case 2: 
              return F_VSITE4FDN;
          default:
              gmx_fatal(FARGS,"Invalid vsites4 type %d",type);
      }
  case d_vsitesn:
    return F_VSITEN; 
  case d_constraints:
  case d_constrainttypes:
    switch (type) {
    case 1:
      return F_CONSTR;
    case 2:
      return F_CONSTRNC;
    default:
      gmx_fatal(FARGS,"Invalid constraints type %d",type);
    }
  case d_settles:
    return F_SETTLE;
  case d_position_restraints:
    switch (type) {
    case 1:
      return F_POSRES;
    case 2:
      gmx_fatal(FARGS,"Water polarization should now be listed under [ water_polarization ]\n");
    default:
      gmx_fatal(FARGS,"Invalid position restraint type %d",type);
    }
  case d_polarization:
    return F_POLARIZATION;
  case d_thole_polarization:
    return F_THOLE_POL;
  case d_water_polarization:
    return F_WATER_POL;
  case d_angle_restraints:
    return F_ANGRES;
  case d_angle_restraints_z:
    return F_ANGRESZ;
  case d_distance_restraints:
    return F_DISRES;
  case d_orientation_restraints:
    return F_ORIRES;
  case d_dihedral_restraints:
    return F_DIHRES;
  default:
    gmx_fatal(FARGS,"invalid directive %s in ifunc_index (%s:%s)",
		dir2str(d),__FILE__,__LINE__);
  }
  return -1;
}
コード例 #12
0
ファイル: topdirs.c プロジェクト: pdalcin/Gromacs_GA
void DS_Init(DirStack **DS)
{
  if (necessary==NULL) {
    int i;

    snew(necessary,d_maxdir);
    set_nec(&(necessary[d_defaults]),d_none);
    set_nec(&(necessary[d_atomtypes]),d_defaults,d_none);
    set_nec(&(necessary[d_bondtypes]),d_atomtypes,d_none);
    set_nec(&(necessary[d_constrainttypes]),d_atomtypes,d_none);
    set_nec(&(necessary[d_pairtypes]),d_atomtypes,d_none);
    set_nec(&(necessary[d_angletypes]),d_atomtypes,d_none);
    set_nec(&(necessary[d_dihedraltypes]),d_atomtypes,d_none);
    set_nec(&(necessary[d_nonbond_params]),d_atomtypes,d_none);
    set_nec(&(necessary[d_moleculetype]),d_atomtypes,d_none);
    set_nec(&(necessary[d_atoms]),d_moleculetype,d_none);
    set_nec(&(necessary[d_vsites2]),d_atoms,d_none);
    set_nec(&(necessary[d_vsites3]),d_atoms,d_none);
    set_nec(&(necessary[d_vsites4]),d_atoms,d_none);
    set_nec(&(necessary[d_vsitesn]),d_atoms,d_none);
    set_nec(&(necessary[d_bonds]),d_atoms,d_none);
    set_nec(&(necessary[d_exclusions]),d_bonds,d_constraints,d_settles,d_none);
    set_nec(&(necessary[d_pairs]),d_atoms,d_none);
    set_nec(&(necessary[d_pairs_nb]),d_atoms,d_none);
    set_nec(&(necessary[d_angles]),d_atoms,d_none);
    set_nec(&(necessary[d_polarization]),d_atoms,d_none);
    set_nec(&(necessary[d_water_polarization]),d_atoms,d_none);
    set_nec(&(necessary[d_thole_polarization]),d_atoms,d_none);
    set_nec(&(necessary[d_dihedrals]),d_atoms,d_none);
    set_nec(&(necessary[d_constraints]),d_atoms,d_none);
    set_nec(&(necessary[d_settles]),d_atoms,d_none);
    set_nec(&(necessary[d_system]),d_moleculetype,d_none);
    set_nec(&(necessary[d_molecules]),d_system,d_none);
    set_nec(&(necessary[d_position_restraints]),d_atoms,d_none);
    set_nec(&(necessary[d_angle_restraints]),d_atoms,d_none);
    set_nec(&(necessary[d_angle_restraints_z]),d_atoms,d_none);
    set_nec(&(necessary[d_distance_restraints]),d_atoms,d_none);
    set_nec(&(necessary[d_orientation_restraints]),d_atoms,d_none);
    set_nec(&(necessary[d_dihedral_restraints]),d_atoms,d_none);
    set_nec(&(necessary[d_mcbonds]), d_atoms, d_bonds,d_none);
    set_nec(&(necessary[d_mcangles]), d_atoms, d_angles,d_none);
    set_nec(&(necessary[d_mcdihedrals]), d_atoms, d_dihedrals,d_none);
    for(i=0; (i<d_maxdir); i++) {
      if (debug)
	fprintf(debug,"%20s:  ",dir2str((directive)i));
      if(necessary[i]) {
	directive d;
	int       j=0;
	do {
	  d=necessary[i][j++];
	  if (debug)
	    fprintf(debug,"%20s  ",dir2str(d));
	} while (d!=d_none);
      }
      if (debug)
	fprintf(debug,"\n");
    }
  } 
  *DS = NULL;

}
コード例 #13
0
ファイル: perf_report.cpp プロジェクト: zeno40/convnet
void perf_report(const prb_t *p, const res_t *r, const char *pstr) {
    const auto &t = r->timer;
    const int max_len = 400;
    int rem_len = max_len - 1;
    char buffer[max_len], *buf = buffer;

#   define DPRINT(...) do { \
        int l = snprintf(buf, rem_len, __VA_ARGS__); \
        buf += l; rem_len -= l; \
    } while(0)

    auto modifier2mode = [](char c) {
        if (c == '-') return benchdnn_timer_t::min;
        if (c == '0') return benchdnn_timer_t::avg;
        if (c == '+') return benchdnn_timer_t::max;
        return benchdnn_timer_t::min;
    };

    auto modifier2unit = [](char c) {
        if (c == 'K') return 1e3;
        if (c == 'M') return 1e6;
        if (c == 'G') return 1e9;
        return 1e0;
    };

    double ops = 2. * p->oc * p->mb * p->ic * p->ih * p->iw * p->id;

    const char *pt = perf_template;
    char c;

    while ((c = *pt++) != '\0') {
        if (c != '%') { *buf++ = c; rem_len--; continue; }

        c = *pt++;

        benchdnn_timer_t::mode_t mode = benchdnn_timer_t::min;
        double unit = 1e0;

        if (c == '-' || c == '0' || c == '+') {
            mode = modifier2mode(c);
            c = *pt++;
        }

        if (c == 'K' || c == 'M' || c == 'G') {
            unit = modifier2unit(c);
            c = *pt++;
        }

        if (c == 'd')
            DPRINT("%s", pstr);
        else if (c == 'D')
            DPRINT("" IFMT "," IFMT "," IFMT "," IFMT "," IFMT "," IFMT "",
                    p->mb, p->oc, p->ic, p->id, p->ih, p->iw);
        else if (c == 'n')
            DPRINT("%s", p->name);
        else if (c == 'z')
            DPRINT("%s", dir2str(p->dir));
        else if (c == 'q')
            DPRINT("%s", cfg2str(p->cfg));
        else if (c == 't')
            DPRINT("%g", t.ms(mode) / unit);
        else if (c == 'O')
            DPRINT("%g", ops / unit);
        else if (c == 'p')
            DPRINT("%g", ops / t.ms(mode) / unit * 1e3);
        else
            []() { SAFE(FAIL, CRIT); return 0; }();
    }

    *buf = '\0';
    assert(rem_len >= 0);

#   undef DPRINT
    print(0, "%s\n", buffer);
}