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/main.c
ViewVC logotype

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

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

revision 1270, Sun Jun 5 12:01:52 2011 UTC revision 1271, Mon Jun 6 02:45:57 2011 UTC
# Line 13  Line 13 
13  #include <assert.h>  #include <assert.h>
14  #include <Diderot/diderot.h>  #include <Diderot/diderot.h>
15  #include "clinfo.h"  #include "clinfo.h"
16    #include <sys/sysctl.h>
17    #include <sys/stat.h>
18    
19  // NOTE: we probably should put this in a file that supports runtime printing  // NOTE: we probably should put this in a file that supports runtime printing
20  static bool     VerboseFlg = false;  static bool     VerboseFlg = false;
# Line 29  Line 31 
31  };  };
32    
33  extern float getOutf (void *self);  extern float getOutf (void *self);
34    extern void Diderot_GPU_Init (cl_device_id device);
35    
36  int main (int argc, const char **argv)  int main (int argc, const char **argv)
37  {  {
# Line 48  Line 51 
51    
52    // run the generated global initialization code    // run the generated global initialization code
53  if (VerboseFlg) printf("initializing globals ...\n");  if (VerboseFlg) printf("initializing globals ...\n");
54      Diderot_InitGlobals ();  
55      /* Globals are loaded from the openCL code
56      //  Diderot_InitGlobals();
57    
58    
59    
60    /***** FIXME: OpenCL specific stuff goes here.  Things to do:    /***** FIXME: OpenCL specific stuff goes here.  Things to do:
61     **     **
# Line 57  Line 64 
64     ** 3) run strands to termination     ** 3) run strands to termination
65     ** 4) load results from GPU     ** 4) load results from GPU
66     **/     **/
67      Diderot_World_t *wrld = Diderot_Initially ();  // this may not be right for OpenCL  
68      /* FIXME: For now we'll just use the very first platform */
69      printf("name:%s\n",clInfo->platforms[0].devices[0].name);
70      Diderot_GPU_Init(clInfo->platforms[0].devices[0].id);
71    
72    
73    
74    /*    Diderot_World_t *wrld = Diderot_Initially ();  // this may not be right for OpenCL
75    
76    // here we have the final state of all of the strands in the "in" buffer    // here we have the final state of all of the strands in the "in" buffer
77      FILE *outS = fopen("mip.txt", "w");      FILE *outS = fopen("mip.txt", "w");
78      if (outS == NULL) {      if (outS == NULL) {
79          fprintf (stderr, "Cannot open output file\n");          fprintf (stderr, "Cannot open output file\n");
80          exit (8);          exit (8);
81        }*/
82    }
83    /* Loads the Kernel from a file */
84    char * loadKernel (const char * filename)
85    {
86        struct stat statbuf;
87        FILE *fh;
88        char *source;
89    
90        fh = fopen(filename, "r");
91        if (fh == 0)
92            return 0;
93    
94        stat(filename, &statbuf);
95        source = (char *) malloc(statbuf.st_size + 1);
96        fread(source, statbuf.st_size, 1, fh);
97        source[statbuf.st_size] = '\0';
98    
99        printf("Reading worked fine!\n");
100        return source;
101      }      }
102    
103    /***** FIXME: output results to outS *****/    /***** FIXME: output results to outS
104    
105      fclose (outS);      fclose (outS);
106    
# Line 75  Line 109 
109      return 0;      return 0;
110    
111  }  }
   
   
112  // this should be the part of the scheduler  // this should be the part of the scheduler
113  void *Diderot_AllocStrand (Strand_t *strand)  void *Diderot_AllocStrand (Strand_t *strand)
114  {  {
# Line 152  Line 184 
184  {  {
185      assert (i < wrld->numStrands);      assert (i < wrld->numStrands);
186      return !wrld->status[i];      return !wrld->status[i];
187  }  }*/

Legend:
Removed from v.1270  
changed lines
  Added in v.1271

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