Skip to content

Commit 55da7b5

Browse files
author
Wolf
committed
Removed bitalign/opcode patching code. It's dead, and no one else is gonna do it.
1 parent c536243 commit 55da7b5

7 files changed

+6
-190
lines changed

Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ sgminer_SOURCES += pool.c pool.h
4444
sgminer_SOURCES += algorithm.c algorithm.h
4545
sgminer_SOURCES += config_parser.c config_parser.h
4646
sgminer_SOURCES += events.c events.h
47-
sgminer_SOURCES += ocl/patch_kernel.c ocl/patch_kernel.h
4847
sgminer_SOURCES += ocl/build_kernel.c ocl/build_kernel.h
4948
sgminer_SOURCES += ocl/binary_kernel.c ocl/binary_kernel.h
5049

ocl.c

+4-34
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,6 @@ static float get_opencl_version(cl_device_id device)
168168
return version;
169169
}
170170

171-
static bool get_opencl_bit_align_support(cl_device_id *device)
172-
{
173-
char extensions[1024];
174-
const char * camo = "cl_amd_media_ops";
175-
char *find;
176-
cl_int status;
177-
178-
status = clGetDeviceInfo(*device, CL_DEVICE_EXTENSIONS, 1024, (void *)extensions, NULL);
179-
if (status != CL_SUCCESS) {
180-
return false;
181-
}
182-
find = strstr(extensions, camo);
183-
return !!find;
184-
}
185-
186171
static cl_int create_opencl_command_queue(cl_command_queue *command_queue, cl_context *context, cl_device_id *device, cl_command_queue_properties cq_properties)
187172
{
188173
cl_int status;
@@ -262,8 +247,6 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
262247
return NULL;
263248
}
264249

265-
clState->hasBitAlign = get_opencl_bit_align_support(&devices[gpu]);
266-
267250
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), (void *)&preferred_vwidth, NULL);
268251
if (status != CL_SUCCESS) {
269252
applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT", status);
@@ -544,9 +527,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
544527

545528
build_data->kernel_path = (*opt_kernel_path) ? opt_kernel_path : NULL;
546529
build_data->work_size = clState->wsize;
547-
build_data->has_bit_align = clState->hasBitAlign;
548530
build_data->opencl_version = get_opencl_version(devices[gpu]);
549-
build_data->patch_bfi = needs_bfi_patch(build_data);
550531

551532
strcpy(build_data->binary_filename, filename);
552533
build_data->binary_filename[strlen(filename) - 3] = 0x00; // And one NULL terminator, cutting off the .cl suffix.
@@ -572,23 +553,13 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
572553
return NULL;
573554
}
574555

575-
if (save_opencl_kernel(build_data, clState->program)) {
576-
/* Program needs to be rebuilt, because the binary was patched */
577-
if (build_data->patch_bfi) {
578-
clReleaseProgram(clState->program);
579-
clState->program = load_opencl_binary_kernel(build_data);
580-
}
581-
}
582-
else {
583-
if (build_data->patch_bfi)
584-
quit(1, "Could not save kernel to file, but it is necessary to apply BFI patch");
585-
}
556+
// If it doesn't work, oh well, build it again next run
557+
save_opencl_kernel(build_data, clState->program);
586558
}
587559

588560
// Load kernels
589-
applog(LOG_NOTICE, "Initialising kernel %s with%s bitalign, %spatched BFI, nfactor %d, n %d",
590-
filename, clState->hasBitAlign ? "" : "out", build_data->patch_bfi ? "" : "un",
591-
algorithm->nfactor, algorithm->n);
561+
applog(LOG_NOTICE, "Initialising kernel %s with nfactor %d, n %d",
562+
filename, algorithm->nfactor, algorithm->n);
592563

593564
/* get a kernel object handle for a kernel with the given name */
594565
clState->kernel = clCreateKernel(clState->program, "search", &status);
@@ -597,7 +568,6 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
597568
return NULL;
598569
}
599570

600-
601571
clState->n_extra_kernels = algorithm->n_extra_kernels;
602572
if (clState->n_extra_kernels > 0) {
603573
unsigned int i;

ocl.h

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ typedef struct __clState {
2424
cl_mem MidstateBuf;
2525
cl_mem padbuffer8;
2626
unsigned char cldata[80];
27-
bool hasBitAlign;
2827
bool goffset;
2928
cl_uint vwidth;
3029
size_t max_work_size;

ocl/build_kernel.c

+2-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <stdio.h>
22
#include "build_kernel.h"
3-
#include "patch_kernel.h"
43
#include "miner.h"
54

65
static char *file_contents(const char *filename, int *length)
@@ -52,6 +51,7 @@ static char *file_contents(const char *filename, int *length)
5251
return (char*)buffer;
5352
}
5453

54+
// This should NOT be in here! -- Wolf9466
5555
void set_base_compiler_options(build_kernel_data *data)
5656
{
5757
char buf[255];
@@ -61,51 +61,17 @@ void set_base_compiler_options(build_kernel_data *data)
6161

6262
sprintf(buf, "w%dl%d", (int)data->work_size, (int)sizeof(long));
6363
strcat(data->binary_filename, buf);
64-
65-
if (data->has_bit_align) {
66-
strcat(data->compiler_options, " -D BITALIGN");
67-
applog(LOG_DEBUG, "cl_amd_media_ops found, setting BITALIGN");
68-
} else
69-
applog(LOG_DEBUG, "cl_amd_media_ops not found, will not set BITALIGN");
7064

7165
if (data->kernel_path) {
7266
strcat(data->compiler_options, " -I \"");
7367
strcat(data->compiler_options, data->kernel_path);
7468
strcat(data->compiler_options, "\"");
7569
}
7670

77-
if (data->patch_bfi) {
78-
strcat(data->compiler_options, " -D BFI_INT");
79-
applog(LOG_DEBUG, "BFI_INT patch requiring device found, patched source with BFI_INT");
80-
} else
81-
applog(LOG_DEBUG, "BFI_INT patch requiring device not found, will not BFI_INT patch");
82-
8371
if (data->opencl_version < 1.1)
8472
strcat(data->compiler_options, " -D OCL1");
8573
}
8674

87-
bool needs_bfi_patch(build_kernel_data *data)
88-
{
89-
if (data->has_bit_align &&
90-
(data->opencl_version < 1.2) &&
91-
(strstr(data->platform, "Cedar") ||
92-
strstr(data->platform, "Redwood") ||
93-
strstr(data->platform, "Juniper") ||
94-
strstr(data->platform, "Cypress" ) ||
95-
strstr(data->platform, "Hemlock" ) ||
96-
strstr(data->platform, "Caicos" ) ||
97-
strstr(data->platform, "Turks" ) ||
98-
strstr(data->platform, "Barts" ) ||
99-
strstr(data->platform, "Cayman" ) ||
100-
strstr(data->platform, "Antilles" ) ||
101-
strstr(data->platform, "Wrestler" ) ||
102-
strstr(data->platform, "Zacate" ) ||
103-
strstr(data->platform, "WinterPark" )))
104-
return true;
105-
else
106-
return false;
107-
}
108-
10975
cl_program build_opencl_kernel(build_kernel_data *data, const char *filename)
11076
{
11177
int pl;
@@ -198,18 +164,10 @@ bool save_opencl_kernel(build_kernel_data *data, cl_program program)
198164
goto out;
199165
}
200166

201-
/* Patch the kernel if the hardware supports BFI_INT but it needs to
202-
* be hacked in */
203-
if (data->patch_bfi) {
204-
if (kernel_bfi_patch(binaries[slot], binary_sizes[slot]) != 0) {
205-
quit(1, "Could not patch BFI_INT, please report this issue.");
206-
}
207-
}
208-
209167
/* Save the binary to be loaded next time */
210168
binaryfile = fopen(data->binary_filename, "wb");
211169
if (!binaryfile) {
212-
/* Not fatal, just means we build it again next time, unless BFI patch is needed */
170+
/* Not fatal, just means we build it again next time */
213171
applog(LOG_DEBUG, "Unable to create file %s", data->binary_filename);
214172
goto out;
215173
} else {

ocl/build_kernel.h

-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ typedef struct _build_kernel_data {
2323
char sgminer_path[255];
2424
const char *kernel_path;
2525
size_t work_size;
26-
bool has_bit_align;
27-
bool patch_bfi;
2826
float opencl_version;
2927
} build_kernel_data;
3028

31-
bool needs_bfi_patch(build_kernel_data *data);
3229
cl_program build_opencl_kernel(build_kernel_data *data, const char *filename);
3330
bool save_opencl_kernel(build_kernel_data *data, cl_program program);
3431
void set_base_compiler_options(build_kernel_data *data);

ocl/patch_kernel.c

-97
This file was deleted.

ocl/patch_kernel.h

-10
This file was deleted.

0 commit comments

Comments
 (0)