~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to tune/threads/probe_nthr.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Sylvestre Ledru, Sébastien Villemot
  • Date: 2013-06-11 15:58:16 UTC
  • mfrom: (1.1.4) (25 sid)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20130611155816-8xeeiziu1iml040c
Tags: 3.10.1-1
[ Sylvestre Ledru ]
* New upstream release (Closes: #609287)

[ Sébastien Villemot ]
* Provide architectural defaults (i.e. precomputed timings) for all
  release archs (except armel and mips for the time being, due to slow
  porterboxes). This will make the package build much faster and should
  eliminate transient build failures due to excessive variance in the
  timings.
* Move symlinks for lib{cblas,f77blas,atlas,lapack_atlas} out of the
  libblas.so.3 alternative and make them always present, so that
  software relying on these libs do not break when another alternative
  is selected for BLAS
* ATLAS now has improved ARM support with native asm constructs. This required
  the following tunes:
  + armel-is-v4t.diff: new patch, prevents FTBFS on armel; otherwise,
    ATLAS uses asm constructs too recent for the platform (armel is only v4t)
  + debian/rules: on armhf, define the ATL_ARM_HARDFP flag; otherwise the asm
    constructs use the soft-float ABI for passing floating points
  + on armhf, ensure that -mfloat-abi=softfp and -mcpu=vfpv3 flags are never
    used; this is implemented via a patch (armhf.diff) and by the use of fixed
    archdefs
* The generic package is now built without multi-threading, because otherwise
  the package fails to build on some single-processor machines (this required
  the introduction of a patch: fix-non-threaded-build.diff). As a side effect,
  the build of the custom package gracefully handles non-threaded
  builds. (Closes: #602524)
* Add libblas.a as slave in the libblas.so alternative (Closes: #701921)
* Add symlinks for lib{f77blas,atlas}.a in /usr/lib (Closes: #666203)
* Modify shlibs file of libatlas3-base, such that packages using
  libblas/liblapack depend on any BLAS/LAPACK alternative, while packages
  depending on ATLAS-specific libraries (e.g. libatlas.so) depend specifically
  on libatlas3-base.
* corei1.diff: remove patch, applied upstream
* Use my @debian.org email address
* Remove obsolete DM-Upload-Allowed flag
* Switch VCS to git
* Remove Conflicts/Replaces against pre-squeeze packages
* libatlas-base-dev now provides libblas.so, as libblas-dev
* No longer use -Wa,--noexecstack in CFLAGS, it makes the package FTBFS
* Do not use POWER3 arch for powerpcspe port (Closes: #701068)
* Bump to debhelper compat level 9
* README.Debian: mention that devscripts is needed to compile the custom
  package (Closes: #697431)
* Bump Standards-Version to 3.9.4. As a consequence, add Built-Using
  fields because the package embeds stuff from liblapack-pic

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "atlas_taffinity.h"
 
2
#include "atlas_misc.h"
 
3
#include "assert.h"
 
4
 
 
5
#if defined(__MINGW32__) || defined(__MINGW64__)
 
6
 
 
7
int slashdrivesub(char *ln)
 
8
/*
 
9
 * replaces \\c\ with c:\, returns change in string length
 
10
 * this version required for older cygwins
 
11
 */
 
12
{
 
13
   char *sp, *lp=ln, ctmp;
 
14
   int nrep=0;
 
15
   do
 
16
   {
 
17
      sp = strstr(lp, "\\\\");
 
18
      if (sp && strlen(sp) > 3)
 
19
      {
 
20
         if (sp[2] == 'a' || sp[2] == 'b' || sp[2] == 'c' || sp[2] == 'd' ||
 
21
             sp[2] == 'e' || sp[2] == 'f' || sp[2] == 'g' || sp[2] == 'h')
 
22
         {
 
23
            if (sp[3] == '\\')
 
24
            {
 
25
               ctmp = sp[2];
 
26
               sp[0] = sp[2];
 
27
               sp[1] = ':';
 
28
               sp[2] = '\\';
 
29
               for (lp=sp+3; *lp = lp[1]; lp++);
 
30
               lp = sp + 3;
 
31
               nrep++;
 
32
            }
 
33
            else lp = sp + 2;
 
34
         }
 
35
         else lp = sp + 2;
 
36
      }
 
37
      else lp = sp + 2;
 
38
   }
 
39
   while (sp);
 
40
   return(-nrep);
 
41
}
 
42
 
 
43
int cygdrivesub(char *ln)
 
44
/*
 
45
 * replaces \cygdrive\c\ with c:\, returns change in string length
 
46
 * this version works cygnus version 1.1.0
 
47
 */
 
48
{
 
49
   char *sp;
 
50
   int i=0;
 
51
 
 
52
   while(sp = strstr(ln, "\\cygdrive\\"))
 
53
   {
 
54
      i++;
 
55
      sp[0] = sp[10];
 
56
      sp[1] = ':';
 
57
      sp[2] = '\\';
 
58
      sp += 3;
 
59
      while (*sp = sp[9]) sp++;
 
60
   }
 
61
   return( slashdrivesub(ln) - (i*9) );
 
62
}
 
63
 
 
64
void slashsub(char *ln)
 
65
/*
 
66
 * changes forward slash of unix to backslash of windoze
 
67
 */
 
68
{
 
69
   int i;
 
70
   for (i=0; ln[i]; i++) if (ln[i] == '/') ln[i] = '\\';
 
71
}
 
72
 
 
73
#endif
 
74
 
 
75
 
 
76
void PrintUsage(char *nam)
 
77
{
 
78
   fprintf(stderr, "\nUSAGE: %s [-o <outfile>]\n", nam);
 
79
   exit(-1);
 
80
}
 
81
 
 
82
FILE *GetFlags(int nargs, char **args)
 
83
{
 
84
   int i;
 
85
   FILE *fpout=stdout;
 
86
 
 
87
   for (i=1; i < nargs; i++)
 
88
   {
 
89
      if (args[i][0] != '-') PrintUsage(args[0]);
 
90
      switch(args[i][1])
 
91
      {
 
92
      case 'o':
 
93
         #if defined(__MINGW32__) || defined(__MINGW64__)
 
94
         {
 
95
            char *wp;
 
96
            wp = malloc(sizeof(char)*(strlen(args[++i])+1));;
 
97
            strcpy(wp, args[i]);
 
98
            slashsub(wp);
 
99
            cygdrivesub(wp);
 
100
            fpout = fopen(wp, "w");
 
101
            free(wp);
 
102
         }
 
103
         #else
 
104
            fpout = fopen(args[++i], "w");
 
105
         #endif
 
106
         assert(fpout);
 
107
         break;
 
108
      default:
 
109
         PrintUsage(args[0]);
 
110
      }
 
111
   }
 
112
   return(fpout);
 
113
}
 
114
 
 
115
void getLaunchOrder(int P, int *lo)
 
116
{
 
117
   int i, j, k, stop, dest;
 
118
 
 
119
   for (i=0; (1<<i) < P; i++)
 
120
   lo[0] = 0;
 
121
   k = 1;
 
122
   for (i--; i >= 0; i--)
 
123
   {
 
124
      stop = k;
 
125
      for (j=0; j < stop; j++)
 
126
      {
 
127
         dest = lo[j] + (1<<i);
 
128
         if (dest < P)
 
129
            lo[k++] = dest;
 
130
         if (k == P)
 
131
            return;
 
132
      }
 
133
   }
 
134
}
 
135
 
 
136
int main(int nargs, char **args)
 
137
{
 
138
   FILE *fpout;
 
139
   int i, j, k, P;
 
140
   int *lo;
 
141
   fpout = GetFlags(nargs, args);
 
142
 
 
143
   fprintf(fpout, "  /* This file generated by %s */\n", __FILE__);
 
144
   fprintf(fpout, "#ifndef ATLAS_NTHREADS_H\n   #define ATLAS_NTHREADS_H\n\n");
 
145
   #if !defined(ATL_PAFF_WIN64) && !defined(ATL_PAFF_WIN)
 
146
      fprintf(fpout, "#include \"pthread.h\"\n");
 
147
   #endif
 
148
   #if ATL_NCPU != 0
 
149
      P = ATL_NCPU;
 
150
   #elif defined(ATL_AFF_NUMID)
 
151
      P = ATL_AFF_NUMID;
 
152
   #else
 
153
      P = 4;
 
154
   #endif
 
155
   #if defined(ATL_AFF_NUMID)
 
156
      #if ATL_NCPU > ATL_AFF_NUMID
 
157
         fprintf(fpout,
 
158
         "/*\n * I should have tested if NTHREADS = %d(NCPU) or %d(NAFFIDs)\n");
 
159
         fprintf(fpout, " * is better.  For now, assuming %d\n */", ATL_NCPU);
 
160
      #endif
 
161
   #endif
 
162
   fprintf(fpout, "   #define ATL_NTHREADS %d\n", P);
 
163
   for (i=0; (1<<i) < P; i++);
 
164
   fprintf(fpout, "   #define ATL_NTHRPOW2 %d\n", i);
 
165
   lo = malloc(P*sizeof(int));
 
166
   getLaunchOrder(P, lo);
 
167
   fprintf(fpout, "   #ifdef ATL_LAUNCHORDER\n");
 
168
   fprintf(fpout, "       static int ATL_launchorder[%d] = {0", P);
 
169
   for (i=1; i < P; i++)
 
170
      fprintf(fpout, ",%d", lo[i]);
 
171
   fprintf(fpout, "};\n   #endif\n");
 
172
   #if defined(ATL_AFF_NUMID) && !defined(ATL_RANK_IS_PROCESSORID)
 
173
      fprintf(fpout, "   #if defined(ATL_RANK2ID)\n");
 
174
      fprintf(fpout, "       static int ATL_rank2ID[%d] = {%d",
 
175
              P, ATL_affinityIDs[0]);
 
176
      for (i=1; i < P; i++)
 
177
         fprintf(fpout, ",%d", ATL_affinityIDs[i%ATL_AFF_NUMID]);
 
178
      fprintf(fpout, "};\n   #endif\n");
 
179
   #endif
 
180
   fprintf(fpout, "\n#endif\n");
 
181
   fclose(fpout);
 
182
   return(0);
 
183
}