static void init(struct fmt_main *_self)
{
    char build_opts[64];
    static char valgo[sizeof(ALGORITHM_NAME) + 8] = "";

    self = _self;

    opencl_preinit();
    /* VLIW5 does better with just 2x vectors due to GPR pressure */
    if (!options.v_width && amd_vliw5(device_info[gpu_id]))
        v_width = 2;
    else
        v_width = opencl_get_vector_width(gpu_id, sizeof(cl_int));

    if (v_width > 1) {
        /* Run vectorized kernel */
        snprintf(valgo, sizeof(valgo),
                 ALGORITHM_NAME " %ux", v_width);
        self->params.algorithm_name = valgo;
    }

    snprintf(build_opts, sizeof(build_opts),
             "-DHASH_LOOPS=%u -DOUTLEN=%u "
             "-DPLAINTEXT_LENGTH=%u -DV_WIDTH=%u",
             HASH_LOOPS, OUTLEN, PLAINTEXT_LENGTH, v_width);
    opencl_init("$JOHN/kernels/pbkdf1_hmac_sha1_kernel.cl",
                gpu_id, build_opts);

    pbkdf1_init = clCreateKernel(program[gpu_id], "pbkdf1_init", &ret_code);
    HANDLE_CLERROR(ret_code, "Error creating kernel");
    crypt_kernel = pbkdf1_loop = clCreateKernel(program[gpu_id], "pbkdf1_loop", &ret_code);
    HANDLE_CLERROR(ret_code, "Error creating kernel");
    pbkdf1_final = clCreateKernel(program[gpu_id], "pbkdf1_final", &ret_code);
    HANDLE_CLERROR(ret_code, "Error creating kernel");
}
static void init(struct fmt_main *self) {
	int 	i ;

	//Prepare OpenCL environment.
	opencl_preinit();

	///Allocate memory
	key_host = mem_calloc(self -> params.max_keys_per_crypt, sizeof(*key_host)) ;
	dcc_hash_host = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * MAX_KEYS_PER_CRYPT) ;
	dcc2_hash_host = (cl_uint*)mem_alloc(4 * sizeof(cl_uint) * MAX_KEYS_PER_CRYPT) ;
	hmac_sha1_out  = (cl_uint*)mem_alloc(5 * sizeof(cl_uint) * MAX_KEYS_PER_CRYPT) ;

	memset(dcc_hash_host, 0, 4 * sizeof(cl_uint) * MAX_KEYS_PER_CRYPT) ;
	memset(dcc2_hash_host, 0, 4 * sizeof(cl_uint) * MAX_KEYS_PER_CRYPT) ;

	/* Read LWS/GWS prefs from config or environment */
	opencl_get_user_preferences(FORMAT_LABEL);

	for( i=0; i < get_number_of_devices_in_use(); i++)
		select_device(gpu_device_list[i], self) ;

	dcc2_warning() ;

	if (pers_opts.target_enc == UTF_8) {
		self->params.plaintext_length *= 3;
		if (self->params.plaintext_length > 125)
			self->params.plaintext_length = 125;
	}
}
Exemplo n.º 3
0
static void init(struct fmt_main *self) {
	saved_key = mem_calloc(BF_N, sizeof(*saved_key)) ;
	global_work_size = 0 ;

	//Prepare OpenCL environment.
	opencl_preinit();

	// Check if specific LWS/GWS was requested
	opencl_get_user_preferences(FORMAT_LABEL);

	// BF_select_device(platform,device);
	//platform_id = get_platform_id(gpu_id);
        BF_select_device(self) ;
	keys_mode = 'a' ;
	sign_extension_bug = 0 ;
	//fprintf(stderr, "****Please see 'opencl_bf_std.h' for device specific optimizations****\n");
}
Exemplo n.º 4
0
Arquivo: john.c Projeto: mimaun/Rose
static void john_fork(void)
{
	int i, pid;
	int *pids;

	fflush(stdout);
	fflush(stderr);

#if HAVE_MPI
/*
 * We already initialized MPI before knowing this is actually a fork session.
 * So now we need to tear that "1-node MPI session" down before forking, or
 * all sorts of funny things might happen.
 */
	mpi_teardown();
#endif
/*
 * It may cost less memory to reset john_main_process to 0 before fork()'ing
 * the children than to do it in every child process individually (triggering
 * copy-on-write of the entire page).  We then reset john_main_process back to
 * 1 in the parent, but this only costs one page, not one page per child.
 */
	john_main_process = 0;

	pids = mem_alloc_tiny((options.fork - 1) * sizeof(*pids),
	    sizeof(*pids));

	for (i = 1; i < options.fork; i++) {
		switch ((pid = fork())) {
		case -1:
			pexit("fork");

		case 0:
			sig_preinit();
			options.node_min += i;
			options.node_max = options.node_min;
#if HAVE_OPENCL
			// Poor man's multi-device support
			if (options.gpu_devices->count &&
			    strstr(database.format->params.label, "-opencl")) {
				// Pick device to use for this child
				opencl_preinit();
				gpu_id =
				    gpu_device_list[i % get_number_of_devices_in_use()];
				platform_id = get_platform_id(gpu_id);

				// Hide any other devices from list
				gpu_device_list[0] = gpu_id;
				gpu_device_list[1] = -1;

				// Postponed format init in forked process
				fmt_init(database.format);
			}
#endif
			if (rec_restoring_now) {
				unsigned int node_id = options.node_min;
				rec_done(-2);
				rec_restore_args(1);
				if (node_id != options.node_min + i)
					fprintf(stderr,
					    "Inconsistent crash recovery file:"
					    " %s\n", rec_name);
				options.node_min = options.node_max = node_id;
			}
			sig_init_child();
			return;

		default:
			pids[i - 1] = pid;
		}
	}

#if HAVE_OPENCL
	// Poor man's multi-device support
	if (options.gpu_devices->count &&
	    strstr(database.format->params.label, "-opencl")) {
		// Pick device to use for mother process
		opencl_preinit();
		gpu_id = gpu_device_list[0];
		platform_id = get_platform_id(gpu_id);

		// Hide any other devices from list
		gpu_device_list[1] = -1;

		// Postponed format init in mother process
		fmt_init(database.format);
	}
#endif
	john_main_process = 1;
	john_child_pids = pids;
	john_child_count = options.fork - 1;

	options.node_max = options.node_min;
}