Guest User

cudadump

a guest
Apr 27th, 2010
873
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*! \file cudadump.c
  2.   \author Travis Goodspeed
  3.   \brief Ugly hack of a CUDA PTX Dumper
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8.  
  9. //Large buffer
  10. #define BUFLEN 0x400000
  11.  
  12. //! Dumps CUDA scripts from a file.
  13. int main(int argc, char **argv){
  14.   char buf[BUFLEN];
  15.   char c;
  16.   const char *ptx;
  17.   long count=0;
  18.   long found=0;
  19.  
  20.   fprintf(stderr,"USAGE:\n\t./cudadump <tests/gpuspy >app.ptx\n");
  21.  
  22.   //Look for PTX strings.
  23.   while(!feof(stdin)){
  24.     buf[count++]=c=fgetc(stdin);
  25.     buf[count+1]=0;
  26.     if(!c){ //End of C string
  27.       count=0;
  28.       ptx=strstr(buf,".version");
  29.       if(ptx){
  30.     printf("%s\n",ptx);
  31.     found++;
  32.       }
  33.       buf[0]=0;
  34.     }
  35.     //Reset if nothing promising after half buffer.
  36.     if(count>(BUFLEN>>1) && !strstr(buf,".version"))
  37.       count=0;
  38.     //Warn if buffer blown.
  39.     if(count>BUFLEN-1){
  40.       count=0;
  41.       printf("// Buffer exceeded.  Might have lost a PTX.\n");
  42.       fprintf(stderr,
  43.           "// Buffer exceeded.  Might have lost a PTX.\n");
  44.     }
  45.   }
  46.   printf("// Found %li PTX assemblies.\n",found);
  47.   return 0;
  48. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×