Browse Source

Remove duplicated function

tweaked
elbandi 9 years ago
parent
commit
854cd2544e
  1. 23
      driver-opencl.c
  2. 11
      ocl.c
  3. 1
      ocl.h

23
driver-opencl.c

@ -1037,28 +1037,9 @@ static void set_threads_hashes(unsigned int vectors, unsigned int compute_shader @@ -1037,28 +1037,9 @@ static void set_threads_hashes(unsigned int vectors, unsigned int compute_shader
unsigned int minthreads, __maybe_unused int *intensity, __maybe_unused int *xintensity,
__maybe_unused int *rawintensity, algorithm_t *algorithm)
{
unsigned int threads = 0;
while (threads < minthreads) {
unsigned int threads;
if (*rawintensity > 0) {
threads = *rawintensity;
}
else if (*xintensity > 0) {
threads = compute_shaders * ((algorithm->xintensity_shift) ? (1 << (algorithm->xintensity_shift + *xintensity)) : *xintensity);
}
else {
threads = 1 << (algorithm->intensity_shift + *intensity);
}
if (threads < minthreads) {
if (likely(*intensity < MAX_INTENSITY)) {
(*intensity)++;
}
else {
threads = minthreads;
}
}
}
threads = calc_global_threads(compute_shaders, minthreads, intensity, xintensity, rawintensity, algorithm);
*globalThreads = threads;
*hashes = threads * vectors;

11
ocl.c

@ -180,17 +180,16 @@ static cl_int create_opencl_command_queue(cl_command_queue *command_queue, cl_co @@ -180,17 +180,16 @@ static cl_int create_opencl_command_queue(cl_command_queue *command_queue, cl_co
return status;
}
// Copied from set_threads_hashes() in driver-opencl.c
static size_t CalcGlobalThreads(unsigned int compute_shaders, unsigned int minthreads, __maybe_unused int *intensity, __maybe_unused int *xintensity, __maybe_unused int *rawintensity, algorithm_t *algorithm)
unsigned int calc_global_threads(unsigned int compute_shaders, unsigned int minthreads, __maybe_unused int *intensity, __maybe_unused int *xintensity, __maybe_unused int *rawintensity, algorithm_t *algorithm)
{
size_t threads = 0;
unsigned int threads = 0;
while (threads < minthreads) {
if (*rawintensity > 0) {
threads = *rawintensity;
}
else if (*xintensity > 0) {
threads = compute_shaders * ((algorithm->xintensity_shift)?(1 << (algorithm->xintensity_shift + *xintensity)):*xintensity);
threads = compute_shaders * ((algorithm->xintensity_shift) ? (1 << (algorithm->xintensity_shift + *xintensity)) : *xintensity);
}
else {
threads = 1 << (algorithm->intensity_shift + *intensity);
@ -206,7 +205,7 @@ static size_t CalcGlobalThreads(unsigned int compute_shaders, unsigned int minth @@ -206,7 +205,7 @@ static size_t CalcGlobalThreads(unsigned int compute_shaders, unsigned int minth
}
}
return(threads);
return threads;
}
_clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *algorithm)
@ -869,7 +868,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg @@ -869,7 +868,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
// By the way, if you change the intensity between now and opencl_scanhash()
// calculating the global thread count, God help you.
if (algorithm->type == ALGO_QUARK) {
clState->GlobalThreadCount = CalcGlobalThreads(clState->compute_shaders, clState->wsize, &cgpu->intensity, &cgpu->xintensity, &cgpu->rawintensity, &cgpu->algorithm);
clState->GlobalThreadCount = calc_global_threads(clState->compute_shaders, clState->wsize, &cgpu->intensity, &cgpu->xintensity, &cgpu->rawintensity, &cgpu->algorithm);
for (int i = 0; i < 6; ++i) {
clState->BranchBuffer[i] = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, sizeof(cl_uint) * (clState->GlobalThreadCount + 2), NULL, &status);
if (status != CL_SUCCESS && !clState->BranchBuffer[i]) {

1
ocl.h

@ -29,5 +29,6 @@ typedef struct __clState { @@ -29,5 +29,6 @@ typedef struct __clState {
extern int clDevicesNum(void);
extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *algorithm);
extern unsigned int calc_global_threads(unsigned int compute_shaders, unsigned int minthreads, int *intensity, int *xintensity, int *rawintensity, algorithm_t *algorithm);
#endif /* OCL_H */

Loading…
Cancel
Save