Skip to content

Commit

Permalink
Fixed fread issues under Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycros committed Jul 5, 2011
1 parent 1f80998 commit 52d6e7c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ocl.c
Expand Up @@ -14,7 +14,7 @@
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netdb.h>
#endif

#include <time.h>
Expand All @@ -31,7 +31,7 @@ extern int opt_worksize;

char *file_contents(const char *filename, int *length)
{
FILE *f = fopen(filename, "r");
FILE *f = fopen(filename, "rb");
void *buffer;

if (!f) {
Expand Down Expand Up @@ -88,7 +88,7 @@ int clDevicesNum() {
if (!strcmp(pbuff, "Advanced Micro Devices, Inc."))
{
break;
}
}
}
free(platforms);
}
Expand Down Expand Up @@ -384,7 +384,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
strcat(binaryfilename, numbuf);
strcat(binaryfilename, ".bin");

binaryfile = fopen(binaryfilename, "r");
binaryfile = fopen(binaryfilename, "rb");
if (!binaryfile) {
if (opt_debug)
applog(LOG_DEBUG, "No binary found, generating from source");
Expand Down Expand Up @@ -420,7 +420,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
}
if (opt_debug)
applog(LOG_DEBUG, "Loaded binary image %s", binaryfilename);

free(binaries[gpu]);
goto built;
}
Expand Down Expand Up @@ -479,15 +479,15 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
applog(LOG_DEBUG, "cl_amd_media_ops not found, will not BFI_INT patch");

clState->program = clCreateProgramWithSource(clState->context, 1, (const char **)&source, sourceSize, &status);
if (status != CL_SUCCESS)
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Loading Binary into cl_program (clCreateProgramWithSource)");
return NULL;
}

/* create a cl program executable for all the devices specified */
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
if (status != CL_SUCCESS)
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
size_t logSize;
Expand All @@ -496,7 +496,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
char *log = malloc(logSize);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
applog(LOG_INFO, "%s", log);
return NULL;
return NULL;
}

status = clGetProgramInfo( clState->program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*nDevices, binary_sizes, NULL );
Expand Down Expand Up @@ -559,7 +559,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
}

clState->program = clCreateProgramWithBinary(clState->context, 1, &devices[gpu], &binary_sizes[gpu], (const unsigned char **)&binaries[gpu], &status, NULL);
if (status != CL_SUCCESS)
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Loading Binary into cl_program (clCreateProgramWithBinary)");
return NULL;
Expand All @@ -570,7 +570,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
free(rawsource);

/* Save the binary to be loaded next time */
binaryfile = fopen(binaryfilename, "w");
binaryfile = fopen(binaryfilename, "wb");
if (!binaryfile) {
/* Not a fatal problem, just means we build it again next time */
if (opt_debug)
Expand All @@ -593,7 +593,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)

/* create a cl program executable for all the devices specified */
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
if (status != CL_SUCCESS)
if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
size_t logSize;
Expand All @@ -602,7 +602,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
char *log = malloc(logSize);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
applog(LOG_INFO, "%s", log);
return NULL;
return NULL;
}

/* get a kernel object handle for a kernel with the given name */
Expand Down

0 comments on commit 52d6e7c

Please sign in to comment.