Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/lib/cl-target/clinfo.c
ViewVC logotype

Diff of /branches/pure-cfg/src/lib/cl-target/clinfo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1471, Sat Aug 13 11:46:41 2011 UTC revision 1472, Fri Aug 19 01:54:43 2011 UTC
# Line 20  Line 20 
20    
21  static bool GetDevices (PlatformInfo_t *plat);  static bool GetDevices (PlatformInfo_t *plat);
22    
 STATIC_INLINE void *alloc (size_t szb)  
 {  
     void *p = malloc(szb);  
     if (p == 0) {  
         fprintf (stderr, "fatal error: unable to allocate %d bytes of memory\n", (int)szb);  
         exit (1);  
     }  
     return p;  
 }  
   
 #define NEW(ty)         (ty *)alloc(sizeof(ty))  
 #define NEWVEC(ty,n)    (ty *)alloc(sizeof(ty) * (n))  
 #define NEWSTR(s)       strcpy((char *)alloc(strlen(s)+1), s)  
   
23  #define CHECK(call)     do {                                                    \  #define CHECK(call)     do {                                                    \
24          cl_int __sts = call;                                                    \          cl_int __sts = call;                                                    \
25          if (__sts != CL_SUCCESS) {                                              \          if (__sts != CL_SUCCESS) {                                              \
# Line 136  Line 122 
122          CHECK(clGetDeviceInfo (          CHECK(clGetDeviceInfo (
123              devices[i], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &(dev->maxWGSize), 0));              devices[i], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &(dev->maxWGSize), 0));
124          size_t szb = sizeof(size_t) * dev->maxWIDims;          size_t szb = sizeof(size_t) * dev->maxWIDims;
125          dev->maxWISize = (size_t *) alloc (szb);          dev->maxWISize = (size_t *) CheckedAlloc (szb);
126          CHECK(clGetDeviceInfo (devices[i], CL_DEVICE_MAX_WORK_ITEM_SIZES, szb, dev->maxWISize, 0));          CHECK(clGetDeviceInfo (devices[i], CL_DEVICE_MAX_WORK_ITEM_SIZES, szb, dev->maxWISize, 0));
127          CHECK(clGetDeviceInfo (          CHECK(clGetDeviceInfo (
128              devices[i], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &(dev->globalMemSzb), 0));              devices[i], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &(dev->globalMemSzb), 0));
# Line 179  Line 165 
165              devices[i], CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &(dev->floatWid), 0));              devices[i], CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &(dev->floatWid), 0));
166          CHECK(clGetDeviceInfo (          CHECK(clGetDeviceInfo (
167              devices[i], CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &(dev->doubleWid), 0));              devices[i], CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &(dev->doubleWid), 0));
168          // determine the compute-unit width
169            if (isCPUDevice(dev))
170                dev->cuWidth = 1;
171            else if (isGPUDevice(dev))
172                if (strcasecmp("AMD", dev->vendor) == 0)
173                    dev->cuWidth = 64; // an AMD wavefront is 64-wide
174                else if (strcasecmp("NVIDIA", dev->vendor) == 0)
175                    dev->cuWidth = 32; // an NVIDIA warp is 32-wide
176                else
177                    dev->cuWidth = 1; // FIXME: not sure what this should be?
178            else
179                dev->cuWidth = 1; // FIXME: not sure what this should be?
180    
181      }      }
182    
183      free(devices);      free(devices);
# Line 214  Line 213 
213              fprintf (outS, "\n");              fprintf (outS, "\n");
214              fprintf (outS, "      Address size:            %d\n", dev->addrBits);              fprintf (outS, "      Address size:            %d\n", dev->addrBits);
215              fprintf (outS, "      Endianess:               %s\n", dev->littleEndian ? "LITTLE" : "BIG");              fprintf (outS, "      Endianess:               %s\n", dev->littleEndian ? "LITTLE" : "BIG");
216              fprintf (outS, "      Num. compute units:      %d\n", dev->numCUs);              fprintf (outS, "      Num. compute units:      %d", dev->numCUs);
217                if (dev->cuWidth > 1)
218                    fprintf (outS, " * %d\n", dev->cuWidth);
219                else
220                    fprintf (outS, "\n");
221              fprintf (outS, "      Max. dimensions:         %d\n", dev->maxWIDims);              fprintf (outS, "      Max. dimensions:         %d\n", dev->maxWIDims);
222              fprintf (outS, "      Max. work group size:    %ld\n", (long)(dev->maxWGSize));              fprintf (outS, "      Max. work group size:    %ld\n", (long)(dev->maxWGSize));
223              fprintf (outS, "      Max. work items:         ");              fprintf (outS, "      Max. work items:         ");

Legend:
Removed from v.1471  
changed lines
  Added in v.1472

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0