📄 spewmakeinc.c
字号:
int THREADS=0; int Use3DNow=0; /* this needs to come from getflags */ int ncpu; int USEDEFL1, USEARCHDEF; char *targ, *sp, *pmake, *flapack; char *comps[3*NCOMP], *comp, *flags, *srcdir, *blddir, *f2cdefs, *cdefs; char *outfile, *smaflags, *dmaflags, *f77lib, *gccflags, *goodgcc; char targarg[256], ln[1024]; FILE *fpout; char *adnames[NARDEF] = {"sKERNDEF", "dKERNDEF", "sMMDEF", "dMMDEF"}; GetFlags(nargs, args, &verb, &OS, (enum ASMDIA*) &asmb, &vecexts, &mach, &mhz, &ptrbits, &ncpu, comps, &gccflags, &outfile, &srcdir, &blddir, &USEDEFL1, &USEARCHDEF, &nof77, &f2cdefs, &cdefs, &pmake, &flapack, &smaflags, &dmaflags, &f77lib, &l2size, &targ); if (ncpu > 1) THREADS = 1; if (!outfile) fpout = stdout; else fpout = fopen(outfile, "w"); assert(fpout); assert(srcdir && blddir);/* * Update l2size, and set f2cdefs/cdefs if they are null */ if (!l2size) l2size = 4*1024*1024; else l2size *= 1024; if (!f2cdefs) f2cdefs = "";/* * Append any appended flags, and then we have just compilers and flags */ for (i=2*NCOMP; i < 3*NCOMP; i++) { if (comps[i]) { comps[i-NCOMP] = NewAppendedString(comps[i-NCOMP], comps[i]); free(comps[i]); comps[i] = NULL; } }/* * If any C compiler is unspecified, use it to specify the others * Use DKC preferentially if it is specified */ if (comps[DKC_] && comps[NCOMP+DKC_]) k = DKC_; else { k = -1; for (i=0; i < F77_; i++) { if (comps[i] && comps[NCOMP+i]) { k = i; break; } } if (k < 0) { fprintf(stderr, "Need a valid C compiler and flags\n"); exit(100); } } for (i=0; i < F77_; i++) { if (!comps[i]) comps[i] = comps[k]; if (!comps[NCOMP+i]) comps[NCOMP+i] = comps[NCOMP+k]; }/* * If F77 compiler unspecified or nof77 asserted, set it to ICC for linking */ if (!comps[F77_] || nof77) { comps[F77_] = comps[ICC_]; comps[NCOMP+F77_] = comps[NCOMP+ICC_]; }/* * Find dominant ISA extension */ ISAX = 0; for (i=1; i < NISA && !ISAX; i++) if (vecexts & (1<<i)) ISAX = i; fprintf(fpout, "# ----------------------------\n"); fprintf(fpout, "# Make.inc for ATLAS3.8.0\n"); fprintf(fpout, "# ----------------------------\n\n"); fprintf(fpout, "# ----------------------------------\n"); fprintf(fpout, "# Make sure we get the correct shell\n"); fprintf(fpout, "# ----------------------------------\n"); fprintf(fpout, " SHELL = /bin/sh\n\n"); fprintf(fpout, "# -------------------------------------------------\n"); fprintf(fpout, "# Name indicating the platform to configure BLAS to\n"); fprintf(fpout, "# -------------------------------------------------\n"); fprintf(fpout, " ARCH = %s", machnam[mach]); fprintf(fpout, "%d", ptrbits); if (ISAX) fprintf(fpout, "%s", ISAXNAM[ISAX]); fprintf(fpout, "\n\n"); fprintf(fpout, "# ----------------------------\n"); fprintf(fpout, "# Paths to various directories\n"); fprintf(fpout, "# ----------------------------\n"); fprintf(fpout, " BLDdir = %s\n", blddir); fprintf(fpout, " SRCdir = %s\n", srcdir); fprintf(fpout, " INCAdir = $(BLDdir)/include\n"); fprintf(fpout, " INCSdir = $(SRCdir)/include\n"); fprintf(fpout, " BINdir = $(BLDdir)/bin\n"); fprintf(fpout, " LIBdir = $(BLDdir)/lib\n\n"); fprintf(fpout, " SYSdir = $(BLDdir)/tune/sysinfo\n"); fprintf(fpout, " GMMdir = $(BLDdir)/src/blas/gemm\n"); fprintf(fpout, " GMVdir = $(BLDdir)/src/blas/gemv\n"); fprintf(fpout, " GR1dir = $(BLDdir)/src/blas/ger\n"); fprintf(fpout, " L1Bdir = $(BLDdir)/src/blas/level1\n"); fprintf(fpout, " L2Bdir = $(BLDdir)/src/blas/level2\n"); fprintf(fpout, " L3Bdir = $(BLDdir)/src/blas/level3\n"); fprintf(fpout, " TSTdir = $(BLDdir)/src/testing\n"); fprintf(fpout, " AUXdir = $(BLDdir)/src/auxil\n"); fprintf(fpout, " CBLdir = $(BLDdir)/interfaces/blas/C/src\n"); fprintf(fpout, " FBLdir = $(BLDdir)/interfaces/blas/F77/src\n"); fprintf(fpout, " PTSdir = $(BLDdir)/src/pthreads\n"); fprintf(fpout, " MMTdir = $(BLDdir)/tune/blas/gemm\n"); fprintf(fpout, " MVTdir = $(BLDdir)/tune/blas/gemv\n"); fprintf(fpout, " R1Tdir = $(BLDdir)/tune/blas/ger\n"); fprintf(fpout, " L1Tdir = $(BLDdir)/tune/blas/level1\n"); fprintf(fpout, " L3Tdir = $(BLDdir)/tune/blas/level3\n"); fprintf(fpout, "\n"); fprintf(fpout,"# ---------------------------------------------------------------------\n"); fprintf(fpout,"# Name and location of scripts for running executables during tuning\n"); fprintf(fpout,"# ---------------------------------------------------------------------\n"); fprintf(fpout, " ATLRUN = $(BLDdir)/bin/ATLrun.sh\n"); fprintf(fpout, " ATLFWAIT = $(BLDdir)/bin/xatlas_waitfile\n\n"); fprintf(fpout, "# ---------------------\n"); fprintf(fpout, "# Libraries to be built\n"); fprintf(fpout, "# ---------------------\n"); fprintf(fpout, " ATLASlib = $(LIBdir)/libatlas.a\n"); fprintf(fpout, " CBLASlib = $(LIBdir)/libcblas.a\n"); fprintf(fpout, " F77BLASlib = $(LIBdir)/libf77blas.a\n"); if (THREADS) { fprintf(fpout, " PTCBLASlib = $(LIBdir)/libptcblas.a\n"); fprintf(fpout, " PTF77BLASlib = $(LIBdir)/libptf77blas.a\n"); } fprintf(fpout, " LAPACKlib = $(LIBdir)/liblapack.a\n"); fprintf(fpout, " TESTlib = $(LIBdir)/libtstatlas.a\n\n"); fprintf(fpout, "# -------------------------------------------\n"); fprintf(fpout, "# Upper bound on largest cache size, in bytes\n"); fprintf(fpout, "# -------------------------------------------\n"); fprintf(fpout, " L2SIZE = -DL2SIZE=%d\n\n", l2size); fprintf(fpout, "# ---------------------------------------\n"); fprintf(fpout, "# Command setting up correct include path\n"); fprintf(fpout, "# ---------------------------------------\n"); fprintf(fpout, " INCLUDES = -I$(INCAdir) -I$(INCSdir) -I$(INCSdir)/contrib\n\n"); fprintf(fpout, "# -------------------------------------------\n"); fprintf(fpout, "# Defines for setting up F77/C interoperation\n"); fprintf(fpout, "# -------------------------------------------\n"); fprintf(fpout, " F2CDEFS = %s\n\n", f2cdefs); fprintf(fpout, "# ------------------------------\n"); fprintf(fpout, "# Architecture identifying flags\n"); fprintf(fpout, "# ------------------------------\n"); fprintf(fpout, " ARCHDEFS ="); if (OS != OSOther) fprintf(fpout, " -DATL_OS_%s", osnam[OS]); if (mach != MACHOther) fprintf(fpout, " -DATL_ARCH_%s", machnam[mach]); if (mhz) fprintf(fpout, " -DATL_CPUMHZ=%d", mhz); if (OS == OSSunOS) fprintf(fpout, " -DSUN_HR"); if (OSIsWin(OS)) fprintf(fpout, " -DGCCWIN -DUseClock"); for (i=1; i < NISA; i++) if (vecexts & (1<<i)) fprintf(fpout, " -DATL_%s", ISAXNAM[i]); if (Use3DNow) fprintf(fpout, " -DATL_3DNowFLOPS"); if (ptrbits == 64) fprintf(fpout, " -DATL_USE64BITS"); if (mach == IA64Itan || mach == IA64Itan2 ) fprintf(fpout, " -DATL_MAXNREG=128"); if (asmb != ASM_None) fprintf(fpout, " -DATL_%s", ASMNAM[asmb]); if (mach == IA64Itan2) fprintf(fpout, " -DATL_IntelIccBugs");/* * Need up update handling of apple vs. gnu gcc for altivec */#if 0 if (ISAX == ISA_AV && strstr(CC, "gcc") && strstr(MCC, "gcc") && !GccIsApple(CC)) fprintf(fpout, " -DATL_%s -DATL_AVgcc", ISAXNAM[ISAX]);#endif fprintf(fpout, "\n\n"); fprintf(fpout, "# -------------------------------------------------------------------\n"); fprintf(fpout, "# NM is the flag required to name a compiled object/executable\n"); fprintf(fpout, "# OJ is the flag required to compile to object rather than executable\n"); fprintf(fpout, "# These flags are used by all compilers.\n"); fprintf(fpout, "# -------------------------------------------------------------------\n"); fprintf(fpout, " NM = -o\n"); fprintf(fpout, " OJ = -c\n\n"); sprintf(ln, "%s/CONFIG/src/CompMake.txt", srcdir); DisplayFile(ln, fpout, 0); fprintf(fpout, " CDEFS = $(L2SIZE) $(INCLUDES) $(F2CDEFS) $(ARCHDEFS)"); if (cdefs) fprintf(fpout, " %s", cdefs); if (THREADS) { fprintf(fpout, " -DATL_NCPU=%d", ncpu); if (OS == OSFreeBSD) fprintf(fpout, " -D_THREAD_SAFE -D_REENTRANT"); if (OS == OSAIX) fprintf(fpout, " -DIBM_PT_ERROR"); if (OS == OSIRIX) fprintf(fpout, " -D_POSIX_C_SOURCE=199506L"); } if (delay) fprintf(fpout, " -DATL_FOPENDELAY"); fprintf(fpout, "\n\n"); for (i=0; i < NCOMP; i++) { fprintf(fpout, " %s = %s\n", COMPNAME[i], comps[i]); if (i == F77_) fprintf(fpout, " %sFLAGS = %s\n", COMPNAME[i], comps[NCOMP+i]); else if (i == ICC_ || i == XCC_) fprintf(fpout, " %sFLAGS = $(CDEFS) %s\n", COMPNAME[i], comps[NCOMP+i]); else /* non-interf comps don't include CDEFS by default (added later) */ fprintf(fpout, " %sFLAGS = %s\n", COMPNAME[i], comps[NCOMP+i]); } fprintf(fpout, " SMAFLAGS ="); if (smaflags) fprintf(fpout, " %s", smaflags); fprintf(fpout, "\n DMAFLAGS ="); if (dmaflags) fprintf(fpout, " %s", dmaflags); fprintf(fpout, "\n"); fprintf(fpout, " CKC = $(SKC)\n"); fprintf(fpout, " ZKC = $(DKC)\n"); fprintf(fpout, " sKCFLAGS = $(CDEFS) $(SKCFLAGS)\n"); fprintf(fpout, " dKCFLAGS = $(CDEFS) $(DKCFLAGS)\n"); fprintf(fpout, " cKCFLAGS = $(CDEFS) $(SKCFLAGS)\n"); fprintf(fpout, " zKCFLAGS = $(CDEFS) $(DKCFLAGS)\n"); for (i=0; i < NCOMP; i++) { if (i == XCC_) continue; /* do not accept cross-compiler */ j = strlen(comps[i]); if (j >= 3 && comps[i][j-3] == 'g' && comps[i][j-2] == 'c' && comps[i][j-1] == 'c') break; } goodgcc = (j < NCOMP) ? comps[j] : "gcc"; fprintf(fpout, " GOODGCC = %s", goodgcc); if (gccflags) fprintf(fpout, " %s", gccflags); GetGccVers(goodgcc, &i, &j, &k, &k); if (OS == OSOSX && j > 3) /* need bullshit apple annoyance flag */ fprintf(fpout, " -force_cpusubtype_ALL"); sp = GetPtrbitsFlag(OS, mach, ptrbits, goodgcc); if (strlen(sp) > 0) fprintf(fpout, " %s", sp); fprintf(fpout, "\n"); fprintf(fpout, " LDFLAGS ="); if (MachIsX86(mach)) { if (ptrbits == 32) fprintf(fpout, " -melf_i386"); else if (ptrbits == 64) fprintf(fpout, " -melf_x86_64"); } fprintf(fpout, "\n F77SYSLIB = %s\n", f77lib ? f77lib : ""); fprintf(fpout, " BC = $(ICC)\n"); fprintf(fpout, " NCFLAGS = $(ICCFLAGS)\n"); fprintf(fpout, "\n CLINKER = $(ICC)\n CLINKFLAGS = $(ICCFLAGS)\n"); fprintf(fpout, " FLINKER = $(F77)\n FLINKFLAGS = $(F77FLAGS)\n"); fprintf(fpout, " FCLINKFLAGS = $(FLINKFLAGS)"); if (strstr(comps[F77_], "ifort") && !OSIsWin(OS)) fprintf(fpout, " -nofor_main"); fprintf(fpout, "\n ARCHIVER = ar\n"); fprintf(fpout, " ARFLAGS = r\n"); if (OS == OSOSX && MachIsPPC(mach)) fprintf(fpout, " RANLIB = ranlib\n\n"); else fprintf(fpout, " RANLIB = echo\n\n"); fprintf(fpout, "# -------------------------------------\n"); fprintf(fpout, "# tar, gzip, gunzip, and parallel make\n"); fprintf(fpout, "# -------------------------------------\n"); fprintf(fpout, " TAR = tar\n"); fprintf(fpout, " GZIP = gzip\n"); fprintf(fpout, " GUNZIP = gunzip\n"); fprintf(fpout, " PMAKE = %s\n\n", pmake ? pmake : "$(MAKE)");/* * Need to add libs to GetFlags and update GetSysLib to do this right*/ fprintf(fpout, "# ------------------------------------\n"); fprintf(fpout, "# Reference and system libraries\n"); fprintf(fpout, "# ------------------------------------\n"); fprintf(fpout, " BLASlib = \n"); fprintf(fpout, " FBLASlib = \n"); fprintf(fpout, " FLAPACKlib = "); if (flapack) fprintf(fpout, "%s", flapack); fprintf(fpout, "\n"); fprintf(fpout, " SLAPACKlib = \n"); if (THREADS) fprintf(fpout, " LIBS = -lpthread"); else fprintf(fpout, " LIBS ="); if (!OSIsWin(OS)) fprintf(fpout, " -lm"); fprintf(fpout, "\n\n"); fprintf(fpout, "# --------------------------------------------------------------------\n"); fprintf(fpout, "# Compiler names for architectural defaults and flags to atlas_install\n"); fprintf(fpout, "# --------------------------------------------------------------------\n"); for (i=0; i < NCOMP; i++) { sp = NewStringCopy(COMPNAME[i]); for (j=0; sp[j]; j++) sp[j] = tolower(sp[j]); fprintf(fpout, " %sD = ", sp); free(sp);/* * Regardless of actual names, use standard gnu compiler names for defs */ if (CompIsGcc(comps[i])) { if (i == F77_) { GetGccVers(comps[i], &k, &j, &k, &k); if (j < 4) sp = NewStringCopy("g77"); else sp = NewStringCopy("gfortran"); } else sp = NewStringCopy("gcc"); } else { sp = NameWithoutPath(comps[i]); if (!strncmp(sp, "ATLwin_", 7)) sp = NewStringCopy(comps[i]+7); } fprintf(fpout, "%s\n", sp); free(sp); } fprintf(fpout, " INSTFLAGS = -1 %d -a %d\n\n", USEDEFL1, USEARCHDEF); fprintf(fpout, "# ---------------------------------------\n"); fprintf(fpout, "# Generic targets needed by all makefiles\n"); fprintf(fpout, "# ---------------------------------------\n"); fprintf(fpout, "do_it: all\n"); if (delay) { fprintf(fpout, " waitfile = wfdefault\n"); fprintf(fpout, "waitfile:\n\tcd $(BINdir) ; make xatlas_waitfile\n"); fprintf(fpout, "\t$(ATLFWAIT) -s %d -f $(waitfile)\n", delay); } else fprintf(fpout, "waitfile:\n"); if (fpout != stdout && fpout != stderr) fclose(fpout); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -