|
|
@ -144,10 +144,10 @@ void patch_opcodes(char *w, unsigned remaining) |
|
|
|
remaining -= 8; |
|
|
|
remaining -= 8; |
|
|
|
} |
|
|
|
} |
|
|
|
if (opt_debug) { |
|
|
|
if (opt_debug) { |
|
|
|
printf("Potential OP3 instructions identified: " |
|
|
|
applog(LOG_DEBUG, "Potential OP3 instructions identified: " |
|
|
|
"%i BFE_INT, %i BFE_UINT, %i BYTE_ALIGN\n", |
|
|
|
"%i BFE_INT, %i BFE_UINT, %i BYTE_ALIGN", |
|
|
|
count_bfe_int, count_bfe_uint, count_byte_align); |
|
|
|
count_bfe_int, count_bfe_uint, count_byte_align); |
|
|
|
printf("Patched a total of %i BFI_INT instructions\n", patched); |
|
|
|
applog(LOG_DEBUG, "Patched a total of %i BFI_INT instructions", patched); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -316,31 +316,34 @@ _clState *initCl(int gpu, char *name, size_t nameSize) { |
|
|
|
} |
|
|
|
} |
|
|
|
err = clGetProgramInfo( clState->program, CL_PROGRAM_BINARIES, sizeof(char *)*nDevices, binaries, NULL ); |
|
|
|
err = clGetProgramInfo( clState->program, CL_PROGRAM_BINARIES, sizeof(char *)*nDevices, binaries, NULL ); |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
|
|
|
for (i = 0; i < nDevices; i++) { |
|
|
|
for (i = 0; i < nDevices; i++) { |
|
|
|
if (!binaries[i]) |
|
|
|
if (!binaries[i]) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
unsigned remaining = binary_sizes[i]; |
|
|
|
unsigned remaining = binary_sizes[i]; |
|
|
|
char *w = binaries[i]; |
|
|
|
char *w = binaries[i]; |
|
|
|
const int ati_cal_markers = 17; |
|
|
|
unsigned int start, length; |
|
|
|
int j; |
|
|
|
|
|
|
|
for (j = 0; j < ati_cal_markers; j++) { |
|
|
|
/* Find 2nd incidence of .text, and copy the program's
|
|
|
|
if (opt_debug) |
|
|
|
* position and length at a fixed offset from that. Then go |
|
|
|
printf("At %p (%u rem. bytes), searching ATI CAL marker %i\n", |
|
|
|
* back and find the 2nd incidence of \x7ELF (rewind by one |
|
|
|
w, remaining, j); |
|
|
|
* from ELF) and then patch the opcocdes */ |
|
|
|
advance(&w, &remaining, "ATI CAL"); |
|
|
|
advance(&w, &remaining, ".text"); |
|
|
|
if (remaining < 1) |
|
|
|
|
|
|
|
fprintf(stderr, "Only %u rem. bytes\n", remaining), exit(1); |
|
|
|
|
|
|
|
w++; remaining--; |
|
|
|
w++; remaining--; |
|
|
|
|
|
|
|
advance(&w, &remaining, ".text"); |
|
|
|
|
|
|
|
memcpy(&start, w + 285, 4); |
|
|
|
|
|
|
|
memcpy(&length, w + 289, 4); |
|
|
|
|
|
|
|
w = binaries[i]; remaining = binary_sizes[i]; |
|
|
|
|
|
|
|
advance(&w, &remaining, "ELF"); |
|
|
|
|
|
|
|
w++; remaining--; |
|
|
|
|
|
|
|
advance(&w, &remaining, "ELF"); |
|
|
|
|
|
|
|
w--; remaining++; |
|
|
|
|
|
|
|
w += start; remaining -= start; |
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
printf("At %p (%u rem. bytes), to begin patching\n", |
|
|
|
|
|
|
|
w, remaining); |
|
|
|
|
|
|
|
patch_opcodes(w, length); |
|
|
|
} |
|
|
|
} |
|
|
|
if (remaining < 11) |
|
|
|
|
|
|
|
fprintf(stderr, "Only %u rem. bytes\n", remaining), exit(1); |
|
|
|
|
|
|
|
w += 11; remaining -= 11; |
|
|
|
|
|
|
|
patch_opcodes(w, remaining); |
|
|
|
|
|
|
|
exit (0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
status = clReleaseProgram(clState->program); |
|
|
|
status = clReleaseProgram(clState->program); |
|
|
|
if(status != CL_SUCCESS) |
|
|
|
if(status != CL_SUCCESS) |
|
|
|
{ |
|
|
|
{ |
|
|
|