|
|
@ -33,7 +33,6 @@ |
|
|
|
#include "findnonce.h" |
|
|
|
#include "findnonce.h" |
|
|
|
#include "ocl.h" |
|
|
|
#include "ocl.h" |
|
|
|
|
|
|
|
|
|
|
|
extern int opt_vectors; |
|
|
|
|
|
|
|
extern int opt_worksize; |
|
|
|
extern int opt_worksize; |
|
|
|
int opt_platform_id; |
|
|
|
int opt_platform_id; |
|
|
|
|
|
|
|
|
|
|
@ -194,6 +193,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) |
|
|
|
cl_platform_id platform = NULL; |
|
|
|
cl_platform_id platform = NULL; |
|
|
|
char pbuff[256], vbuff[255]; |
|
|
|
char pbuff[256], vbuff[255]; |
|
|
|
cl_platform_id* platforms; |
|
|
|
cl_platform_id* platforms; |
|
|
|
|
|
|
|
cl_uint preferred_vwidth; |
|
|
|
cl_device_id *devices; |
|
|
|
cl_device_id *devices; |
|
|
|
cl_uint numPlatforms; |
|
|
|
cl_uint numPlatforms; |
|
|
|
cl_uint numDevices; |
|
|
|
cl_uint numDevices; |
|
|
@ -319,12 +319,12 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) |
|
|
|
if (!find) |
|
|
|
if (!find) |
|
|
|
clState->hasOpenCL11plus = true; |
|
|
|
clState->hasOpenCL11plus = true; |
|
|
|
|
|
|
|
|
|
|
|
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), (void *)&clState->preferred_vwidth, NULL); |
|
|
|
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), (void *)&preferred_vwidth, NULL); |
|
|
|
if (status != CL_SUCCESS) { |
|
|
|
if (status != CL_SUCCESS) { |
|
|
|
applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT", status); |
|
|
|
applog(LOG_ERR, "Error %d: Failed to clGetDeviceInfo when trying to get CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT", status); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
applog(LOG_DEBUG, "Preferred vector width reported %d", clState->preferred_vwidth); |
|
|
|
applog(LOG_DEBUG, "Preferred vector width reported %d", preferred_vwidth); |
|
|
|
|
|
|
|
|
|
|
|
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), (void *)&clState->max_work_size, NULL); |
|
|
|
status = clGetDeviceInfo(devices[gpu], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), (void *)&clState->max_work_size, NULL); |
|
|
|
if (status != CL_SUCCESS) { |
|
|
|
if (status != CL_SUCCESS) { |
|
|
@ -337,22 +337,24 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) |
|
|
|
* otherwise, and many cards lie about their max so use 256 as max |
|
|
|
* otherwise, and many cards lie about their max so use 256 as max |
|
|
|
* unless explicitly set on the command line. 79x0 cards perform |
|
|
|
* unless explicitly set on the command line. 79x0 cards perform |
|
|
|
* better without vectors */ |
|
|
|
* better without vectors */ |
|
|
|
if (clState->preferred_vwidth > 1) { |
|
|
|
if (preferred_vwidth > 1) { |
|
|
|
if (strstr(name, "Tahiti")) |
|
|
|
if (strstr(name, "Tahiti")) |
|
|
|
clState->preferred_vwidth = 1; |
|
|
|
preferred_vwidth = 1; |
|
|
|
else |
|
|
|
else |
|
|
|
clState->preferred_vwidth = 2; |
|
|
|
preferred_vwidth = 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (opt_vectors) |
|
|
|
if (gpus[gpu].vwidth) |
|
|
|
clState->preferred_vwidth = opt_vectors; |
|
|
|
clState->vwidth = gpus[gpu].vwidth; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
clState->vwidth = preferred_vwidth; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_worksize && opt_worksize <= (int)clState->max_work_size) |
|
|
|
if (opt_worksize && opt_worksize <= (int)clState->max_work_size) |
|
|
|
clState->work_size = opt_worksize; |
|
|
|
clState->work_size = opt_worksize; |
|
|
|
else if (strstr(name, "Tahiti")) |
|
|
|
else if (strstr(name, "Tahiti")) |
|
|
|
clState->work_size = 64; |
|
|
|
clState->work_size = 64; |
|
|
|
else |
|
|
|
else |
|
|
|
clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / |
|
|
|
clState->work_size = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth; |
|
|
|
clState->preferred_vwidth; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create binary filename based on parameters passed to opencl
|
|
|
|
/* Create binary filename based on parameters passed to opencl
|
|
|
|
* compiler to ensure we only load a binary that matches what would |
|
|
|
* compiler to ensure we only load a binary that matches what would |
|
|
@ -428,7 +430,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) |
|
|
|
strcat(binaryfilename, name); |
|
|
|
strcat(binaryfilename, name); |
|
|
|
|
|
|
|
|
|
|
|
strcat(binaryfilename, "v"); |
|
|
|
strcat(binaryfilename, "v"); |
|
|
|
sprintf(numbuf, "%d", clState->preferred_vwidth); |
|
|
|
sprintf(numbuf, "%d", clState->vwidth); |
|
|
|
strcat(binaryfilename, numbuf); |
|
|
|
strcat(binaryfilename, numbuf); |
|
|
|
strcat(binaryfilename, "w"); |
|
|
|
strcat(binaryfilename, "w"); |
|
|
|
sprintf(numbuf, "%d", (int)clState->work_size); |
|
|
|
sprintf(numbuf, "%d", (int)clState->work_size); |
|
|
@ -496,10 +498,10 @@ build: |
|
|
|
char *CompilerOptions = calloc(1, 256); |
|
|
|
char *CompilerOptions = calloc(1, 256); |
|
|
|
|
|
|
|
|
|
|
|
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d", |
|
|
|
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d", |
|
|
|
(int)clState->work_size, clState->preferred_vwidth); |
|
|
|
(int)clState->work_size, clState->vwidth); |
|
|
|
applog(LOG_DEBUG, "Setting worksize to %d", clState->work_size); |
|
|
|
applog(LOG_DEBUG, "Setting worksize to %d", clState->work_size); |
|
|
|
if (clState->preferred_vwidth > 1) |
|
|
|
if (clState->vwidth > 1) |
|
|
|
applog(LOG_DEBUG, "Patched source to suit %d vectors", clState->preferred_vwidth); |
|
|
|
applog(LOG_DEBUG, "Patched source to suit %d vectors", clState->vwidth); |
|
|
|
|
|
|
|
|
|
|
|
if (clState->hasBitAlign) { |
|
|
|
if (clState->hasBitAlign) { |
|
|
|
strcat(CompilerOptions, " -D BITALIGN"); |
|
|
|
strcat(CompilerOptions, " -D BITALIGN"); |
|
|
@ -648,7 +650,7 @@ built: |
|
|
|
free(binary_sizes); |
|
|
|
free(binary_sizes); |
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_INFO, "Initialising kernel %s with%s bitalign, %d vectors and worksize %d", |
|
|
|
applog(LOG_INFO, "Initialising kernel %s with%s bitalign, %d vectors and worksize %d", |
|
|
|
filename, clState->hasBitAlign ? "" : "out", clState->preferred_vwidth, clState->work_size); |
|
|
|
filename, clState->hasBitAlign ? "" : "out", clState->vwidth, clState->work_size); |
|
|
|
|
|
|
|
|
|
|
|
if (!prog_built) { |
|
|
|
if (!prog_built) { |
|
|
|
/* create a cl program executable for all the devices specified */ |
|
|
|
/* create a cl program executable for all the devices specified */ |
|
|
|