diff --git a/src/opencl_rawmd5_fmt.c b/src/opencl_rawmd5_fmt.c index 43a7a2f..0a2705d 100644 --- a/src/opencl_rawmd5_fmt.c +++ b/src/opencl_rawmd5_fmt.c @@ -37,7 +37,7 @@ cl_mem buffer_matched_count; static cl_uint matched_count; cl_mem buffer_bitmaps, buffer_hashtable, buffer_loaded_next_hash; -static cl_int *bitmaps, *hashtable, *loaded_next_hash; +static cl_int *bitmaps[1], *hashtable, *loaded_next_hash; #define MD5_PASSWORD_HASH_SIZE_0 0x10000 #define MD5_PASSWORD_HASH_SIZE_1 0x10000 // 64K @@ -397,7 +397,7 @@ static size_t create_bitmaps_args() HANDLE_CLERROR(ret_code, "Error creating buffe_loaded_next_hash argument"); // allocate CPU memory - bitmaps = malloc(bitmaps_size); + bitmaps[0] = (cl_int*)malloc(bitmaps_size); hashtable = malloc(hashtable_size); loaded_next_hash = malloc(loaded_count * sizeof(cl_int)); @@ -512,7 +512,7 @@ static void reset(struct db_main *db) bitmaps_num = (hash_num+sizeof(cl_uint)*8-1)/(sizeof(cl_uint)*8); hashtable_num = (hash_num >> MD5_HASH_SHR); - memset(bitmaps, 0, bitmaps_num * sizeof(*bitmaps)); + memset(bitmaps[0], 0, bitmaps_num * sizeof(*bitmaps)); // -1 = 0xFF, 0xFFFFFFFF = -1 memset(hashtable, -1, hashtable_num * sizeof(cl_int)); memset(loaded_next_hash, -1, loaded_count * sizeof(cl_int)); @@ -524,10 +524,10 @@ static void reset(struct db_main *db) else hash = loaded_hash[i] & 0xFFFF; - uint index = hash / (sizeof(*bitmaps) * 8); - uint bit_index = hash % (sizeof(*bitmaps) * 8); + uint index = hash / (sizeof(*bitmaps[0]) * 8); + uint bit_index = hash % (sizeof(*bitmaps[0]) * 8); uint val = 1U << bit_index; - bitmaps[index] |= val; + bitmaps[0][index] |= val; hash >>= MD5_HASH_SHR; loaded_next_hash[i] = hashtable[hash]; hashtable[hash] = i; @@ -541,7 +541,7 @@ static void reset(struct db_main *db) /* if (loaded_next_hash[i] != -1) */ /* printf("i: %d, loaded_next_hash: %d \n", i, loaded_next_hash[i]); */ - HANDLE_CLERROR(clEnqueueWriteBuffer(queue[gpu_id], buffer_bitmaps, CL_TRUE, 0, bitmaps_num * sizeof(*bitmaps), bitmaps, 0, NULL, NULL), "failed in clEnqueueWriteBuffer"); + HANDLE_CLERROR(clEnqueueWriteBuffer(queue[gpu_id], buffer_bitmaps, CL_TRUE, 0, bitmaps_num * sizeof(*bitmaps[0]), bitmaps[0], 0, NULL, NULL), "failed in clEnqueueWriteBuffer"); HANDLE_CLERROR(clEnqueueWriteBuffer(queue[gpu_id], buffer_hashtable, CL_TRUE, 0, hashtable_num * sizeof(cl_int), hashtable, 0, NULL, NULL), "failed in clEnqueueWriteBuffer");