Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*! \file cudadump.c
- \author Travis Goodspeed
- \brief Ugly hack of a CUDA PTX Dumper
- */
- #include <stdio.h>
- #include <string.h>
- //Large buffer
- #define BUFLEN 0x400000
- //! Dumps CUDA scripts from a file.
- int main(int argc, char **argv){
- char buf[BUFLEN];
- char c;
- const char *ptx;
- long count=0;
- long found=0;
- fprintf(stderr,"USAGE:\n\t./cudadump <tests/gpuspy >app.ptx\n");
- //Look for PTX strings.
- while(!feof(stdin)){
- buf[count++]=c=fgetc(stdin);
- buf[count+1]=0;
- if(!c){ //End of C string
- count=0;
- ptx=strstr(buf,".version");
- if(ptx){
- printf("%s\n",ptx);
- found++;
- }
- buf[0]=0;
- }
- //Reset if nothing promising after half buffer.
- if(count>(BUFLEN>>1) && !strstr(buf,".version"))
- count=0;
- //Warn if buffer blown.
- if(count>BUFLEN-1){
- count=0;
- printf("// Buffer exceeded. Might have lost a PTX.\n");
- fprintf(stderr,
- "// Buffer exceeded. Might have lost a PTX.\n");
- }
- }
- printf("// Found %li PTX assemblies.\n",found);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement