Make it possible to select the choice of kernel on the command line.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
diff --git a/main.c b/main.c
index 8d8a1ae..6bf7f63 100644
--- a/main.c
+++ b/main.c
@@ -225,6 +225,10 @@ static char current_block[37];
static char datestamp[40];
static char blockdate[40];
+static char *opt_kernel = NULL;
+
+enum cl_kernel chosen_kernel;
+
struct sigaction termhandler, inthandler;
struct thread_q *getq;
@@ -503,6 +507,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--intensity|-I",
forced_int_1010, opt_show_intval, &scan_intensity,
"Intensity of GPU scanning (-10 -> 10, default: dynamic to maintain desktop interactivity)"),
+ OPT_WITH_ARG("--kernel|-k",
+ opt_set_charp, NULL, &opt_kernel,
+ "Select kernel to use (poclbm or phatk - default: auto)"),
#endif
OPT_WITHOUT_ARG("--load-balance",
set_loadbalance, &pool_strategy,
@@ -2488,10 +2495,15 @@ static void *gpuminer_thread(void *userdata)
bool requested = true;
uint32_t total_hashes = 0, hash_div = 1;
- if (clState->hasBitAlign)
- queue_kernel_parameters = &queue_phatk_kernel;
- else
- queue_kernel_parameters = &queue_poclbm_kernel;
+ switch (chosen_kernel) {
+ case KL_POCLBM:
+ queue_kernel_parameters = &queue_poclbm_kernel;
+ break;
+ case KL_PHATK:
+ default:
+ queue_kernel_parameters = &queue_phatk_kernel;
+ break;
+ }
if (opt_dynamic) {
/* Minimise impact on desktop if we want dynamic mode */
@@ -3233,6 +3245,16 @@ int main (int argc, char *argv[])
if (argc != 1)
quit(1, "Unexpected extra commandline arguments");
+ if (opt_kernel) {
+ if (strcmp(opt_kernel, "poclbm") && strcmp(opt_kernel, "phatk"))
+ quit(1, "Invalid kernel name specified - must be poclbm or phatk");
+ if (!strcmp(opt_kernel, "poclbm"))
+ chosen_kernel = KL_POCLBM;
+ else
+ chosen_kernel = KL_PHATK;
+ } else
+ chosen_kernel = KL_NONE;
+
if (total_devices) {
if (total_devices > nDevs)
quit(1, "More devices specified than exist");
diff --git a/miner.h b/miner.h
index b9b1aec..ed30e63 100644
--- a/miner.h
+++ b/miner.h
@@ -308,6 +308,12 @@ struct work {
struct pool *pool;
};
+enum cl_kernel {
+ KL_NONE,
+ KL_POCLBM,
+ KL_PHATK,
+};
+
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern void kill_work(void);
@@ -323,5 +329,6 @@ extern void tq_thaw(struct thread_q *tq);
extern bool test_and_set(bool *var);
extern bool test_and_clear(bool *var);
extern bool successful_connect;
+extern enum cl_kernel chosen_kernel;
#endif /* __MINER_H__ */
diff --git a/ocl.c b/ocl.c
index 311d8d4..4df5cee 100644
--- a/ocl.c
+++ b/ocl.c
@@ -340,10 +340,25 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
char binaryfilename[255];
char numbuf[10];
char filename[16];
- if (clState->hasBitAlign)
- strcpy(filename, "phatk110722.cl");
- else
- strcpy(filename, "poclbm110717.cl");
+
+ if (chosen_kernel == KL_NONE) {
+ if (clState->hasBitAlign)
+ chosen_kernel = KL_PHATK;
+ else
+ chosen_kernel = KL_POCLBM;
+ }
+
+ switch (chosen_kernel) {
+ case KL_POCLBM:
+ strcpy(filename, "poclbm110717.cl");
+ strcpy(binaryfilename, "poclbm110717");
+ break;
+ case KL_PHATK:
+ strcpy(filename, "phatk110722.cl");
+ strcpy(binaryfilename, "phatk110722");
+ break;
+ }
+
FILE *binaryfile;
size_t *binary_sizes;
char **binaries;
@@ -368,12 +383,10 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
return NULL;
}
- strcpy(binaryfilename, name);
- if (clState->hasBitAlign) {
- strcat(binaryfilename, "phatk110722");
+ strcat(binaryfilename, name);
+ if (clState->hasBitAlign)
strcat(binaryfilename, "bitalign");
- } else
- strcat(binaryfilename, "poclbm110717");
+
strcat(binaryfilename, "v");
sprintf(numbuf, "%d", clState->preferred_vwidth);
strcat(binaryfilename, numbuf);