Esempio n. 1
0
void GenIncCases(char pre, char *spc, char *ifp, FILE *fpout, int alpha,
                 int beta, int n, int *ix, int *iy, int *ia, int *ib)
{
   int i;
   for (i=0; i < n; i++)
   {
      if (ia[i] == alpha && ib[i] == beta)
      {
         if (ix[i] != 0 && iy[i] != 0)
            fprintf(fpout, "%s%sif (incx == %d && incy == %d)\n%s{\n",
                    spc, ifp, ix[i], iy[i], spc);
         else if (ix[i] == 0 && iy[i])
            fprintf(fpout, "%s%sif (incy == %d)\n%s{\n", spc, ifp, iy[i], spc);
         else if (iy[i] == 0 && ix[i])
            fprintf(fpout, "%s%sif (incx == %d)\n%s{\n", spc, ifp, ix[i], spc);
         else if (!ifp[0]) /* only general case */
         {
            fprintf(fpout, "%s%s(N, alpha, X, incx, beta, Y, incy);\n", spc,
                    GetNam(pre, alpha, beta, 0, 0));
            fprintf(fpout, "%sreturn;\n", spc);
            return;
         }
         else fprintf(fpout, "%selse\n%s{\n", spc, spc);
         fprintf(fpout, "%s   %s(N, alpha, X, incx, beta, Y, incy);\n", spc,
                 GetNam(pre, alpha, beta, ix[i], iy[i]));
         fprintf(fpout, "%s   return;\n%s}\n", spc, spc);
      }
      ifp = "else ";
   }
}
Esempio n. 2
0
void GenMakefile(char pre, int n, int *ix, int *iy, int *ia, int *ib,
                 FILENODE **bp)
{
   char *cc, *ccflags, *nam, *typ="";
   char ln[32];
   char *rout = "dot";
   int i;
   FILE *fpout;

   if (CONJ) rout="dotc";
   sprintf(ln, "GEN/Make_%c%s", pre, rout);
   fpout = fopen(ln, "w");
   assert(fpout);
   if (pre == 's') typ="SREAL";
   else if (pre == 'd') typ="DREAL";
   else if (pre == 'c')
   {
      if (CONJ) typ="SCPLX -DConj_";
      else typ="SCPLX";
   }
   else if (pre == 'z')
   {
      if (CONJ) typ="DCPLX -DConj_";
      else typ="DCPLX";
   }

   fprintf(fpout, "include Make.inc\n\n");

   fprintf(fpout, "obj = ATL_%c%s.o", pre, rout);
   for (i=0; i < n; i++)
      fprintf(fpout, " %s.o", GetNam(pre, ia[i], ib[i], ix[i], iy[i]));
   fprintf(fpout, "\n\n");

   fprintf(fpout, "all : lib\n%clib : lib\nlib : %c%s.grd\n\n", pre, pre, rout);

   fprintf(fpout, "%c%s.grd : $(obj)\n", pre, rout);
   fprintf(fpout, "\t$(ARCHIVER) $(ARFLAGS) $(ATLASlib) $(obj)\n");
   fprintf(fpout, "\t$(RANLIB) $(ATLASlib)\n");
   fprintf(fpout, "\ttouch %c%s.grd\n", pre, rout);
   fprintf(fpout, "\n");

   sprintf(ln, "ATL_%c%s", pre, rout);
   fprintf(fpout, "%s.o : %s.c\n", ln, ln);
   fprintf(fpout, "\t$(ICC) $(ICCFLAGS) -D%s -o $@ -c %s.c\n", typ, ln);
   for (i=0; i < n; i++)
   {
      nam = GetNam(pre, ia[i], ib[i], ix[i], iy[i]);
      cc = bp[i]->cc;
      ccflags = bp[i]->ccflags;
      if (!cc) cc = (pre == 's' || pre == 'c') ? "$(SKC)" : "$(DKC)";
      if (!ccflags)
         ccflags = (pre == 's' || pre == 'c') ? "$(SKCFLAGS)":"$(DKCFLAGS)";
      fprintf(fpout, "%s.o : %s.c\n", nam, nam);
      fprintf(fpout, "\t%s %s $(CDEFS) -D%s -o $@ -c %s.c\n",
              cc, ccflags, typ, nam);
   }
   fclose(fpout);
}
Esempio n. 3
0
void GenFiles(char pre, int n, int *ix, int *iy, int *ia, int *ib,
              FILENODE **bp)
/*
 * Generates all needed files
 */
{
   int i;
   char *nam, *typ;
   char ln[128];
   FILE *fpout;

   GenMainRout(pre, n, ix, iy, ia, ib, bp);
   GenMakefile(pre, n, ix, iy, ia, ib, bp);
   for (i=0; i < n; i++)
   {
      nam = GetNam(pre, ia[i], ib[i], ix[i], iy[i]);
      sprintf(ln, "GEN/%s.c", nam);
      fpout = fopen(ln, "w");
      assert(fpout);
      fprintf(fpout, "#define ATL_UAXPBY %s\n\n", nam);
      DumpFile(bp[i]->rout, fpout);
      fclose(fpout);
   }
}
Esempio n. 4
0
void GenMainRout(char pre, int n, int *ix, int *iy, int *ia, int *ib,
                 FILENODE **bp)
{
   int i, j, NeedElse=0;
   FILENODE *gp;
   FILE *fpout;
   char *els="else if", *ifs ="if";
   char *spcs="                  ";
   char *spc = spcs+18;
   char ln[64];
   char *dargs="const int, const SCALAR, const TYPE*, const int, const SCALAR, TYPE*, const int";
   char *args="N, alpha, X, incx, beta, Y, incy";

   sprintf(ln, "GEN/ATL_%caxpby.c", pre);
   fpout = fopen(ln, "w");
   assert(fpout);
   fprintf(fpout, "#include \"atlas_misc.h\"\n\n");
   gp = FindGen(n, ix, iy, ia, ib, bp);
   assert(gp);
/*
 * prototype all routines
 */
   for (i=0; i < n; i++)
   {
      fprintf(fpout, "void %s\n   (%s);\n",
              GetNam(pre, ia[i], ib[i], ix[i], iy[i]), dargs);
   }

   fprintf(fpout, "void ATL_%caxpy(const int, const SCALAR, const TYPE*, const int, TYPE*, const int);\n", pre);
   fprintf(fpout, "void ATL_%ccpsc(const int, const SCALAR, const TYPE*, const int, TYPE*, const int);\n", pre);
   fprintf(fpout,
      "void ATL_%cscal(const int, const SCALAR, TYPE*, const int);\n", pre);
   if (pre == 'c' || pre == 'z')
      fprintf(fpout, "void Mjoin(PATLU,axpby)\n   (const int, const TYPE, const TYPE*, const int, const TYPE, TYPE*, const int);\n");

   fprintf(fpout, "\nvoid ATL_%caxpby(const int N, const SCALAR alpha, const TYPE *X, const int incX,\n", pre);
   fprintf(fpout,
      "               const SCALAR beta, TYPE *Y, const int incY)\n{\n");
   fprintf(fpout, "   int incx=incX, incy=incY;\n");
   if (pre == 'c' || pre == 'z')
      fprintf(fpout, "   const TYPE ralpha=(*alpha), ialpha=alpha[1], rbeta=(*beta), ibeta=beta[1];\n");
   fprintf(fpout, "\n   if (N > 0)\n   {\n");
   spc -= 6;
   MangleIncs(fpout, spc, pre);
   GenAlpBetCase(pre, spc, fpout, n, ix, iy, ia, ib);
/*
 * Handle general alpha & beta, specific incs
 */
   fprintf(fpout, "\n");
   for (i=0; i < n-1; i++)
   {
      if (ia[i] != AlphaX || ib[i] != AlphaX) continue;
      if (ix[i] && iy[i])
         fprintf(fpout, "%s%s (incx == %d && incy == %d)\n",
                 spc, ifs, ix[i], iy[i]);
      else if (iy[i]) fprintf(fpout, "%s%s (incy == %d)\n", spc, ifs, iy[i]);
      else if (ix[i]) fprintf(fpout, "%s%s (incx == %d)\n", spc, ifs, ix[i]);
      fprintf(fpout, "%s   %s(%s);\n", spc,
              GetNam(pre, ia[i], ib[i], ix[i], iy[i]), args);
      ifs = els;
      NeedElse = 1;
   }

   if (NeedElse)
   {
      fprintf(fpout, "%selse\n", spc);
      spc -= 3;
   }
   fprintf(fpout, "%s%s(%s);\n", spc,
           GetNam(pre, AlphaX, AlphaX, 0, 0), args);
   fprintf(fpout, "   }\n");
   fprintf(fpout, "}\n");
   fclose(fpout);
}
Esempio n. 5
0
void GenMainRout(char pre, int n, int *ix, int *iy, int *ia, int *ib,
                 FILENODE **bp)
{
   int i, j, NeedElse=0;
   FILENODE *gp;
   FILE *fpout;
   char *els="else if", *ifs ="if";
   char *spcs="                  ";
   char *spc = spcs+18;
   char ln[64];
   char *dargs="const int, const TYPE*, const int";
   char *args="N, X, incx";

   sprintf(ln, "GEN/ATL_%casum.c", pre);
   fpout = fopen(ln, "w");
   assert(fpout);
   fprintf(fpout, "#include \"atlas_misc.h\"\n\n");
   gp = FindGen(n, ix, iy, ia, ib, bp);
   assert(gp);
/*
 * prototype all routines
 */
   for (i=0; i < n; i++)
   {
      fprintf(fpout, "TYPE %s(const int, const TYPE*, const int);\n",
              GetNam(pre, ia[i], ib[i], ix[i], iy[i]));
   }

   if (pre == 'c' || pre == 'z')
      fprintf(fpout,
              "TYPE Mjoin(PATLU,asum)(const int, const TYPE*, const int);\n");

   if (pre == 's' || pre == 'd') fprintf(fpout, "\nTYPE ATL_%casum", pre);
   else if (pre == 'c') fprintf(fpout, "\nTYPE ATL_scasum");
   else fprintf(fpout, "\nTYPE ATL_dzasum");
   fprintf(fpout, "(const int N, const TYPE *X, const int incX)\n{\n");
   fprintf(fpout, "   int incx;\n\n");
   fprintf(fpout, "   if (N > 0)\n   {\n");
   spc -= 6;
   MangleIncs(fpout, spc, pre);
   if (pre == 'c' || pre == 'z')
   {
      fprintf(fpout,
         "%sif (incx==1) return(Mjoin(PATLU,asum)(N<<1, X, 1));\n", spc);
   }
/*
 * Handle specific incX
 */
   for (i=0; i < n-1; i++)
   {
      fprintf(fpout, "%s%s (incx == %d)\n", spc, ifs, ix[i]);
      fprintf(fpout, "%s   return(%s(%s));\n", spc,
              GetNam(pre, ia[i], ib[i], ix[i], iy[i]), args);
      ifs = els;
      NeedElse = 1;
   }

   if (NeedElse)
   {
      fprintf(fpout, "%selse\n", spc);
      spc -= 3;
   }
   fprintf(fpout, "%sreturn(%s(N, X, incx));\n", spc,
           GetNam(pre, AlphaX, AlphaX, 0, 0));
   fprintf(fpout, "   }\n");
   fprintf(fpout, "   return(ATL_rzero);\n");
   fprintf(fpout, "}\n");
   fclose(fpout);
}
Esempio n. 6
0
void GenMainRout(char pre, int n, int *ix, int *iy, int *ia, int *ib,
                 FILENODE **bp)
{
   int i, j, NeedElse=0;
   FILENODE *gp;
   FILE *fpout;
   char *els="else if", *ifs ="if";
   char *spcs="                  ";
   char *spc = spcs+18;
   char ln[64];
   char *dargs="const int, const TYPE*, const int, const TYPE*, const int";
   char *args="N, X, incx, Y, incy";
   char *cargs="N, X, incx, Y, incy, dotc";
   if (pre == 'c' || pre == 'z') args = cargs;

   sprintf(ln, "GEN/ATL_%cdot.c", pre);
   if (CONJ) sprintf(ln, "GEN/ATL_%cdotc.c", pre);
   fpout = fopen(ln, "w");
   assert(fpout);
   fprintf(fpout, "#include \"atlas_misc.h\"\n\n");
   gp = FindGen(n, ix, iy, ia, ib, bp);
   assert(gp);
/*
 * prototype all routines
 */
   for (i=0; i < n; i++)
   {
      if (pre == 'd' || pre == 's')
         fprintf(fpout, "TYPE %s\n   (%s);\n",
                 GetNam(pre, ia[i], ib[i], ix[i], iy[i]), dargs);
      else
         fprintf(fpout, "void %s\n   (%s, TYPE*);\n",
                 GetNam(pre, ia[i], ib[i], ix[i], iy[i]), dargs);
   }


   if (pre == 'c' || pre == 'z')
   {
      if (CONJ)
         fprintf(fpout,
"\nvoid ATL_%cdotc_sub(const int N, const TYPE *X, const int incX,\n", pre);
      else
         fprintf(fpout,
"\nvoid ATL_%cdotu_sub(const int N, const TYPE *X, const int incX,\n", pre);
      fprintf(fpout,
         "                   const TYPE *Y, const int incY, TYPE *dotc)\n{\n");
   }
   else
   {
      fprintf(fpout,
      "\nTYPE ATL_%cdot(const int N, const TYPE *X, const int incX,\n", pre);
      fprintf(fpout, "              const TYPE *Y, const int incY)\n{\n");
   }
   fprintf(fpout, "   int incx=incX, incy=incY;\n\n");
   fprintf(fpout, "   if (N > 0)\n   {\n");
   spc -= 6;
   MangleIncs(fpout, spc, pre);
/*
 * Handle general alpha & beta, specific incs
 */
   fprintf(fpout, "\n");
   for (i=0; i < n-1; i++)
   {
      if (ix[i] && iy[i])
         fprintf(fpout, "%s%s (incx == %d && incy == %d)\n",
                 spc, ifs, ix[i], iy[i]);
      else if (iy[i]) fprintf(fpout, "%s%s (incy == %d)\n", spc, ifs, iy[i]);
      else if (ix[i]) fprintf(fpout, "%s%s (incx == %d)\n", spc, ifs, ix[i]);
      if (pre == 'd' || pre == 's')
         fprintf(fpout, "%s   return(%s(%s));\n", spc,
                 GetNam(pre, ia[i], ib[i], ix[i], iy[i]), args);
      else
         fprintf(fpout, "%s   %s(%s);\n", spc,
                 GetNam(pre, ia[i], ib[i], ix[i], iy[i]), args);
      ifs = els;
      NeedElse = 1;
   }

   if (NeedElse)
   {
      fprintf(fpout, "%selse\n", spc);
      spc -= 3;
   }
   if (pre == 's' || pre == 'd')
      fprintf(fpout, "%sreturn(%s(%s));\n", spc,
              GetNam(pre, AlphaX, AlphaX, 0, 0), args);
   else
   fprintf(fpout, "%s%s(%s);\n", spc,
           GetNam(pre, AlphaX, AlphaX, 0, 0), args);
   fprintf(fpout, "   }\n");
   if (pre == 'd' || pre == 's') fprintf(fpout, "   else return(ATL_rzero);\n");
   else fprintf(fpout, "   else dotc[0] = dotc[1] = ATL_rzero;\n");
   fprintf(fpout, "}\n");
   fclose(fpout);
}