|
|
|
@ -379,22 +379,13 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
@@ -379,22 +379,13 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|
|
|
|
|
|
|
|
|
/* copy over all of the generated binaries. */ |
|
|
|
|
binaries = (char **)malloc( sizeof(char *)*nDevices ); |
|
|
|
|
for( i = 0; i < nDevices; i++ ) { |
|
|
|
|
if (opt_debug) |
|
|
|
|
applog(LOG_DEBUG, "binary size %d : %d", i, binary_sizes[i]); |
|
|
|
|
if( binary_sizes[i] != 0 ) |
|
|
|
|
binaries[i] = (char *)malloc( sizeof(char)*binary_sizes[i] ); |
|
|
|
|
else |
|
|
|
|
binaries[i] = NULL; |
|
|
|
|
} |
|
|
|
|
applog(LOG_DEBUG, "binary size %d : %d", gpu, binary_sizes[gpu]); |
|
|
|
|
binaries[gpu] = (char *)malloc( sizeof(char)*binary_sizes[i] ); |
|
|
|
|
err = clGetProgramInfo( clState->program, CL_PROGRAM_BINARIES, sizeof(char *)*nDevices, binaries, NULL ); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < nDevices; i++) { |
|
|
|
|
if (!binaries[i]) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
unsigned remaining = binary_sizes[i]; |
|
|
|
|
char *w = binaries[i]; |
|
|
|
|
unsigned remaining = binary_sizes[gpu]; |
|
|
|
|
char *w = binaries[gpu]; |
|
|
|
|
unsigned int start, length; |
|
|
|
|
|
|
|
|
|
/* Find 2nd incidence of .text, and copy the program's
|
|
|
|
@ -406,7 +397,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
@@ -406,7 +397,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|
|
|
|
advance(&w, &remaining, ".text"); |
|
|
|
|
memcpy(&start, w + 285, 4); |
|
|
|
|
memcpy(&length, w + 289, 4); |
|
|
|
|
w = binaries[i]; remaining = binary_sizes[i]; |
|
|
|
|
w = binaries[gpu]; remaining = binary_sizes[gpu]; |
|
|
|
|
advance(&w, &remaining, "ELF"); |
|
|
|
|
w++; remaining--; |
|
|
|
|
advance(&w, &remaining, "ELF"); |
|
|
|
@ -416,7 +407,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
@@ -416,7 +407,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
|
|
|
|
|
applog(LOG_DEBUG, "At %p (%u rem. bytes), to begin patching", |
|
|
|
|
w, remaining); |
|
|
|
|
patch_opcodes(w, length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
status = clReleaseProgram(clState->program); |
|
|
|
|
if(status != CL_SUCCESS) |
|
|
|
|
{ |
|
|
|
|