当前位置: 首页>>代码示例>>Java>>正文


Java JCudaDriver.cuModuleGetFunction方法代码示例

本文整理汇总了Java中jcuda.driver.JCudaDriver.cuModuleGetFunction方法的典型用法代码示例。如果您正苦于以下问题:Java JCudaDriver.cuModuleGetFunction方法的具体用法?Java JCudaDriver.cuModuleGetFunction怎么用?Java JCudaDriver.cuModuleGetFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jcuda.driver.JCudaDriver的用法示例。


在下文中一共展示了JCudaDriver.cuModuleGetFunction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fftShift

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int fftShift(Volume3D vol)
{

	if (DEBUG_FLAG)
		fprintf("vol_fftshift\n");
	initCUDA();
	
	if (vol.in_dim == 1) makeComplex(vol);

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z8fftshiftPfPii");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol.getInternalDimension()));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);

	return(0);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:31,代码来源:CUDAVolumeOperator.java

示例2: createLowPassFilter

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D createLowPassFilter(int dimensions, int size[], float dim [], float lp_upper){
	float [] f_max = new float [Volume3D.MAX_DIM];
	float [] f_delta = new float [Volume3D.MAX_DIM];
	CUDAVolume3D vol = (CUDAVolume3D) createVolume(size, dim, 1);
	/* calculate filter boudings */

	VolumeOperator.getFrequencyBoundings(dimensions, size, dim, f_max, f_delta);

	/* create LP filter */
	initCUDA();	

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(size);
	Pointer fDeltaPointer = CUDAUtil.copyToDeviceMemory(f_delta);
	Pointer fMaxPointer = CUDAUtil.copyToDeviceMemory(f_max);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z19createLowPassFilterPfPiS_S_f");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(fDeltaPointer);
	arguments.add(fMaxPointer);
	arguments.add(new Float(lp_upper));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(fDeltaPointer);
	JCuda.cudaFree(fMaxPointer);

	fftShift(vol);
	return vol;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:40,代码来源:CUDAVolumeOperator.java

示例3: upperLimit

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int upperLimit(Volume3D vol, float max)
{

	if (DEBUG_FLAG)
		fprintf("vol_cut_upper\n");

	if (vol.in_dim != 1) {

		fprintf( "vol_abs: Invalid dimension\n");
		return(-1);
	}

	initCUDA();	

	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z10upperLimitPfPiif");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol.in_dim));
	arguments.add(new Float(max));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);

	return(0);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:36,代码来源:CUDAVolumeOperator.java

示例4: mean

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public float mean(Volume3D vol)
{
	
	/* defined for non-complex volumes only */

	if (vol.in_dim != 1) {
		fprintf("vol_max_pos: Invalid inner dimension\n");
		return(0);
	}

	initCUDA();	

	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);
	float [] results = new float [vol.size[2] * vol.size[1]];
	CUdeviceptr resultPointer = CUDAUtil.copyToDeviceMemory(results);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z4meanPfPiiS_");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol.in_dim));
	arguments.add(resultPointer);

	callCUDAFunction(function, arguments);

	CUDAUtil.fetchFromDeviceMemory(results, resultPointer);
	JCuda.cudaFree(sizePointer);

	float m = 0;
	for (int i = 0; i < results.length; i++){
		m += results[i];
	}
	return(m/results.length); 
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:41,代码来源:CUDAVolumeOperator.java

示例5: addScalar

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int addScalar(Volume3D vol,
		float realPart, 
		float imagPart )
{

	if (DEBUG_FLAG)
		fprintf("vol_add_sc\n");


	if (imagPart!=0){
		makeComplex(vol);
	}

	initCUDA();	

	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z9addScalarPfPiiff");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol.in_dim));
	arguments.add(new Float(realPart));
	arguments.add(new Float(imagPart));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	
	return(0);

}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:39,代码来源:CUDAVolumeOperator.java

示例6: abs

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int abs(Volume3D vol)
{

	if (DEBUG_FLAG)
		fprintf("vol_abs\n");

	if (vol.in_dim != 1 && vol.in_dim != 2) {

		fprintf( "vol_abs: Invalid dimension\n");
		return(-1);
	}

	int adaptedWidth = CUDAUtil.iDivUp(vol.size[2], CUDAUtil.gridBlockSize[0]) * CUDAUtil.gridBlockSize[0];
	int adaptedHeight = CUDAUtil.iDivUp(vol.size[1], CUDAUtil.gridBlockSize[1]) * CUDAUtil.gridBlockSize[1];
	int memorySize = adaptedWidth*adaptedHeight*vol.size[0]* 1 * Sizeof.FLOAT;
	CUdeviceptr deviceX = new CUdeviceptr();
	JCuda.cudaMalloc(deviceX, memorySize);

	initCUDA();	
	
	CUDAVolume3D cudaVol = (CUDAVolume3D) vol;

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z3absPfS_Pii");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(cudaVol.getDevicePointer());
	arguments.add(deviceX);
	arguments.add(sizePointer);
	arguments.add(cudaVol.in_dim);
	if (debug) {
		System.out.print("Called init done ");
		printTime();
	}
	callCUDAFunction(function, arguments);
	if (debug) {
		System.out.print("CUDA done ");
		printTime();
	}

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(cudaVol.getDevicePointer());

	cudaVol.setDevicePointer(deviceX);

	float [][][] temp = new float[vol.size[0]][vol.size[1]][vol.size[2]];
	vol.data = null;
	vol.data = temp;
	temp = null;
	vol.in_dim = 1;
	if (debug) {
		System.out.print("Clean up done ");
		printTime();
	}



	return(0);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:67,代码来源:CUDAVolumeOperator.java

示例7: divideByVolume

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int divideByVolume(Volume3D vol1, Volume3D vol2)
{
	int  dim_loop;
	
	if (DEBUG_FLAG)
		fprintf("vol_div\n");

	for (dim_loop=0; dim_loop<vol1.in_dim; dim_loop++)
		if (vol1.size[dim_loop] != vol2.size[dim_loop]) {

			fprintf( "vol_div: Volumes have different sizes\n");
			return(-1);

		}

	if (vol1.in_dim==2 &&  vol2.in_dim==1) {
		makeComplex(vol2);
		CONRAD.gc();
	}

	if (vol1.in_dim==1 &&  vol2.in_dim==2) {
		makeComplex(vol1);
		CONRAD.gc();
	}

	if (vol2.in_dim>2) {

		fprintf( "vol_div: Invalid dimension\n");
		return(0);

	}


	initCUDA();
	CUdeviceptr sizePointer = CUDAUtil.copyToDeviceMemory(vol1.size);
	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
	"_Z6dividePfS_Pii");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol1).getDevicePointer());
	arguments.add(((CUDAVolume3D) vol2).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol1.getInternalDimension()));

	// Calculate new grid size
	gridSize = getGrid(vol1.size);

	if (debug) System.out.println("Calling.");
	callCUDAFunction(function, arguments);
	if (debug) System.out.println("Freeing.");

	JCuda.cudaFree(sizePointer);

	return(0);

}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:59,代码来源:CUDAVolumeOperator.java

示例8: solveMaximumEigenvalue

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D solveMaximumEigenvalue(Volume3D [][] structureTensor)
{
	CUDAVolume3D a11 = (CUDAVolume3D) structureTensor[0][0];
	CUDAVolume3D a12 = (CUDAVolume3D) structureTensor[0][1];
	CUDAVolume3D a13 = (CUDAVolume3D) structureTensor[0][2];
	CUDAVolume3D a22 = (CUDAVolume3D) structureTensor[1][1];
	CUDAVolume3D a23 = (CUDAVolume3D) structureTensor[1][2];
	CUDAVolume3D a33 = (CUDAVolume3D) structureTensor[2][2];
	CUDAVolume3D vol = (CUDAVolume3D) createVolume(a11.size, a11.spacing, a11.getInternalDimension());
	
	initCUDA();

	CUdeviceptr sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);
	
	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z25filt_solve_max_eigenvaluePfS_S_S_S_S_PiiS_");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(a11.getDevicePointer());
	arguments.add(a12.getDevicePointer());
	arguments.add(a13.getDevicePointer());
	arguments.add(a22.getDevicePointer());
	arguments.add(a23.getDevicePointer());
	arguments.add(a33.getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(a11.getInternalDimension());
	arguments.add(vol.getDevicePointer());
	
	CUDAUtil.gridBlockSize[0] /= 2;
	
	gridSize = getGrid(vol.size);

	if (debug) System.out.println("Calling.");
	callCUDAFunction(function, arguments);
	if (debug) System.out.println("Freeing.");

	CUDAUtil.gridBlockSize[0] *= 2;
	
	JCuda.cudaFree(sizePointer);
	
	return(vol);
	
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:46,代码来源:CUDAVolumeOperator.java

示例9: createDirectionalWeights

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D createDirectionalWeights(int dimensions, int size[],
		float dim[], float dir[], int A, FILTER_TYPE t_filt)
{
	Volume3D vol = null;
	float [] f_max = new float [Volume3D.MAX_DIM];
	float [] f_delta = new float [Volume3D.MAX_DIM];
	float r_abs;
	int  dim_loop;


	if (DEBUG_FLAG)
		fprintf("filt_cos2\n"+t_filt);

	vol=createVolume(size, dim, 1);

	/* normalize filter direction */

	r_abs = 0.0f;
	r_abs += dir[0] * dir[0];
	r_abs += dir[1] * dir[1];
	r_abs += dir[2] * dir[2];
	r_abs = (float) Math.sqrt(r_abs);

	for (dim_loop=0; dim_loop<dimensions; dim_loop++)
		dir[dim_loop] /= r_abs;

	if (DEBUG_FLAG) {
		fprintf("  direction = ");
		for (dim_loop=0; dim_loop<dimensions; dim_loop++) {
			fprintf(dir[dim_loop]);
			if (dim_loop<dimensions-1)
				fprintf(", ");
		}
		fprintf("\n");
	}

	/* calculate filter boundings */

	getFrequencyBoundings(dimensions, size, dim, f_max, f_delta);

	// load CUDA stuff.
	initCUDA();

	CUdeviceptr sizePointer = CUDAUtil.copyToDeviceMemory(size);
	CUdeviceptr dirPointer = CUDAUtil.copyToDeviceMemory(dir);
	CUdeviceptr fDeltaPointer = CUDAUtil.copyToDeviceMemory(f_delta);
	CUdeviceptr fMaxPointer = CUDAUtil.copyToDeviceMemory(f_max);

	Integer filt = 0;
	if (t_filt == FILTER_TYPE.QUADRATIC) filt = new Integer(1);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z9filt_cos2PfPiS_S_S_ii");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(dirPointer);
	arguments.add(fDeltaPointer);
	arguments.add(fMaxPointer);
	arguments.add(new Integer(A));
	arguments.add(filt);

	gridSize = getGrid(vol.size);

	if (debug) System.out.println("Calling.");
	callCUDAFunction(function, arguments);
	if (debug) System.out.println("Freeing.");

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(dirPointer);
	JCuda.cudaFree(fDeltaPointer);
	JCuda.cudaFree(fMaxPointer);

	return(vol);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:79,代码来源:CUDAVolumeOperator.java

示例10: createExponentialDirectionalHighPassFilter

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D createExponentialDirectionalHighPassFilter(int dimensions, int size[],
		float dim[], float dir[], int A, float B, float ri,
		FILTER_TYPE t_filt)
{
	Volume3D vol;
	float [] f_max = new float [Volume3D.MAX_DIM];
	float [] f_delta = new float [Volume3D.MAX_DIM];
	float r_abs;
	int   dim_loop;

	if (DEBUG_FLAG)
		fprintf("filt_cos2_r\n"+t_filt);

	vol=createVolume(size, dim, 1);

	/* normalize filter direction */

	r_abs=0;
	for (dim_loop=0; dim_loop<dimensions; dim_loop++)
		r_abs += dir[dim_loop] * dir[dim_loop];
	r_abs = (float) Math.sqrt(r_abs);

	for (dim_loop=0; dim_loop<dimensions; dim_loop++) {
		dir[dim_loop] /= r_abs;
		if (DEBUG_FLAG)
			fprintf("  direction "+dim_loop+" = "+dir[dim_loop]+"\n");
	}

	/* calculate filter boudings */

	getFrequencyBoundings(dimensions, size, dim, f_max, f_delta);

	initCUDA();	

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(size);
	Pointer dirPointer = CUDAUtil.copyToDeviceMemory(dir);
	Pointer fDeltaPointer = CUDAUtil.copyToDeviceMemory(f_delta);
	Pointer fMaxPointer = CUDAUtil.copyToDeviceMemory(f_max);

	Integer filt = 0;
	if (t_filt == FILTER_TYPE.QUADRATIC) filt = 1;

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z11filt_cos2_rPfPiS_S_S_iffi");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(dirPointer);
	arguments.add(fDeltaPointer);
	arguments.add(fMaxPointer);
	arguments.add(new Integer(A));
	arguments.add(new Float(B));
	arguments.add(new Float(ri));
	arguments.add(filt);

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(dirPointer);
	JCuda.cudaFree(fDeltaPointer);
	JCuda.cudaFree(fMaxPointer);

	//((CUDAVolume3D) vol).fetch();
	//vol.getImagePlus(dir[0] + " " +dir[1] + " " +dir[2] +" Cosine Square R").show();
	fftShift(vol);
	//vol.getImagePlus(dir[0] + " " +dir[1] + " " +dir[2] +"Cosine Square R shifted").show();

	return(vol);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:76,代码来源:CUDAVolumeOperator.java

示例11: createHighPassFilter

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D createHighPassFilter(int dimensions, int [] size, float [] dim, int filt_loop, float lp_upper){
	float [][] dir = new float[MAX_FILTERS][Volume3D.MAX_DIM];
	float hp_lower = (float) (10f*Math.PI);   /* was PI*10 LW 2006-01-31 */
	float hp_upper = (float) (10f*Math.PI);   /* was PI    LW 2006-01-31 */
	//float lp_upper = 1.50f;    /* was 1.5   LW 2006-01-31 */
	CUDAVolume3D vol= (CUDAVolume3D) createVolume(size, dim, 1);
	int n_filters;

	float [] f_max = new float [Volume3D.MAX_DIM];
	float [] f_delta = new float [Volume3D.MAX_DIM];
	VolumeOperator.getFrequencyBoundings(dimensions, size, dim, f_max, f_delta);
	/* create HP filter */

	initCUDA();	

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(size);
	Pointer fDeltaPointer = CUDAUtil.copyToDeviceMemory(f_delta);
	Pointer fMaxPointer = CUDAUtil.copyToDeviceMemory(f_max);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z20createHighPassFilterPfPiS_S_fff");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(fDeltaPointer);
	arguments.add(fMaxPointer);
	arguments.add(new Float(lp_upper));
	arguments.add(new Float(hp_lower));
	arguments.add(new Float(hp_upper));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(fDeltaPointer);
	JCuda.cudaFree(fMaxPointer);

	//Volume3D.vol_fftshift(vol);

	filt_get_filt_dirs(vol.dimensions, dir);
	n_filters = filt_get_n_filters(vol.dimensions);

	IJ.showStatus("Computing High Pass Filters");
	IJ.showProgress((((float)(filt_loop))/n_filters));
	CUDAVolume3D filt = (CUDAVolume3D) createDirectionalWeights(vol.dimensions, vol.size, vol.spacing,
			dir[filt_loop] , 1, FILTER_TYPE.NORMAL);

	if (filt==null) {
		fprintf( "filt_make_enhance_filters: Out of memory\n");
		return(null);
	}

	multiply(filt,vol);
	vol.destroy();

	fftShift(filt);
	//filt.getImagePlus("filter"+ filt_loop).show();
	return filt;
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:65,代码来源:CUDAVolumeOperator.java

示例12: makeComplex

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public void makeComplex(Volume3D vol)
{

	if (vol.getInternalDimension() == 2) return;
	if (vol.getInternalDimension() != 1) {
		fprintf("vol_make_comlex: Invalid dimension\n");
		return;
	}

	initCUDA();

	int adaptedWidth = CUDAUtil.iDivUp(vol.size[2], CUDAUtil.gridBlockSize[0]) * CUDAUtil.gridBlockSize[0];
	int adaptedHeight = CUDAUtil.iDivUp(vol.size[1], CUDAUtil.gridBlockSize[1]) * CUDAUtil.gridBlockSize[1];
	int memorySize = adaptedWidth*adaptedHeight*vol.size[0]* 2 * Sizeof.FLOAT;
	CUdeviceptr deviceX = new CUdeviceptr();
	JCuda.cudaMalloc(deviceX, memorySize);
	JCuda.cudaMemset(deviceX, 0, memorySize);

	CUDAVolume3D cudaVol = (CUDAVolume3D) vol;

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z11makeComplexPfS_Pi");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(cudaVol.getDevicePointer());
	arguments.add(deviceX);
	arguments.add(sizePointer);

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(cudaVol.getDevicePointer());

	cudaVol.setDevicePointer(deviceX);

	float [][][] temp = new float [vol.size[0]][vol.size[1]][vol.size[2]*2];

	vol.data = null;
	vol.data = temp;
	temp = null;
	vol.in_dim = 2;

	return;

}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:53,代码来源:CUDAVolumeOperator.java

示例13: createGaussLowPassFilter

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public Volume3D createGaussLowPassFilter(int dimensions, int size[],
		float dim[], float alpha)
{
	Volume3D       vol;
	float []       f_max = new float [Volume3D.MAX_DIM];
	float []       f_delta = new float [Volume3D.MAX_DIM];

	if (DEBUG_FLAG)
		fprintf("filt_gauss\n");

	vol=createVolume(size, dim, 1);

	/* calculate filter boudings */

	VolumeOperator.getFrequencyBoundings(dimensions, size, dim, f_max, f_delta);

	/* create LP filter */
	initCUDA();	

	// Calculate new grid size
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(size);
	Pointer fDeltaPointer = CUDAUtil.copyToDeviceMemory(f_delta);
	Pointer fMaxPointer = CUDAUtil.copyToDeviceMemory(f_max);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z10filt_gaussPfPiS_S_f");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(fDeltaPointer);
	arguments.add(fMaxPointer);
	arguments.add(new Float(alpha));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);
	JCuda.cudaFree(fDeltaPointer);
	JCuda.cudaFree(fMaxPointer);

	fftShift(vol);

	return(vol);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:49,代码来源:CUDAVolumeOperator.java

示例14: sigmoid

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int sigmoid(Volume3D vol,
		float smoothing, float lowValue, float highValue,
		float highPassLowerLevel,  float highPassUpperLevel)
{

	if (DEBUG_FLAG)
		fprintf("vol_sigmoid_th\n");

	if (vol.in_dim != 1) {

		fprintf( "vol_abs: Invalid dimension\n");
		return(-1);
	}

	initCUDA();	

	// Calculate new grid size
	// Sigmoid is requires a lot of registers. Hence we have to reduce the block size a bit.
	CUDAUtil.gridBlockSize[0] /= 2;
	gridSize = getGrid(vol.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z7sigmoidPfPiifffff");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol.in_dim));
	arguments.add(new Float(smoothing));
	arguments.add(new Float(lowValue));
	arguments.add(new Float(highValue));
	arguments.add(new Float(highPassLowerLevel));
	arguments.add(new Float(highPassUpperLevel));

	callCUDAFunction(function, arguments);

	// restore original block size.
	CUDAUtil.gridBlockSize[0] *= 2;

	JCuda.cudaFree(sizePointer);

	return(0);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:48,代码来源:CUDAVolumeOperator.java

示例15: addVolume

import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@Override
public int addVolume(Volume3D vol1, Volume3D vol2)
{
	int  dim_loop;

	if (DEBUG_FLAG)
		fprintf("vol_add\n");

	for (dim_loop=0; dim_loop<vol1.in_dim; dim_loop++)
		if (vol1.size[dim_loop] != vol2.size[dim_loop]) {

			fprintf( "vol_add: Volumes have different sizes\n");
			return(-1);

		}

	/* OBS !!! borde inte behova konvertera vol2 . komplex */

	if (vol1.in_dim==2 &&  vol2.in_dim==1) {
		makeComplex(vol2);
		CONRAD.gc();
	}

	if (vol1.in_dim==1 &&  vol2.in_dim==2){ 
		makeComplex(vol1);
		CONRAD.gc();
	}

	if (vol2.in_dim>2 || vol1.in_dim>2) {

		fprintf( "vol_add: Invalid dimension\n");
		return(-1);

	}

	initCUDA();	

	gridSize = getGrid(vol1.size);

	Pointer sizePointer = CUDAUtil.copyToDeviceMemory(vol1.size);

	CUfunction function = new CUfunction();
	JCudaDriver.cuModuleGetFunction(function, module,
			"_Z9addVolumePfS_Pii");

	ArrayList<Object> arguments = new ArrayList<Object>();
	arguments.add(((CUDAVolume3D) vol1).getDevicePointer());
	arguments.add(((CUDAVolume3D) vol2).getDevicePointer());
	arguments.add(sizePointer);
	arguments.add(new Integer(vol1.in_dim));

	callCUDAFunction(function, arguments);

	JCuda.cudaFree(sizePointer);

	return(0);
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:58,代码来源:CUDAVolumeOperator.java


注:本文中的jcuda.driver.JCudaDriver.cuModuleGetFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。