本文整理汇总了C#中CudaDeviceVariable类的典型用法代码示例。如果您正苦于以下问题:C# CudaDeviceVariable类的具体用法?C# CudaDeviceVariable怎么用?C# CudaDeviceVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CudaDeviceVariable类属于命名空间,在下文中一共展示了CudaDeviceVariable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DCTQuantFwd8x8LS
/// <summary>
/// Forward DCT, quantization and level shift part of the JPEG encoding.
/// Input is expected in 8x8 macro blocks and output is expected to be in 64x1
/// macro blocks.
/// </summary>
/// <param name="src">Source image.</param>
/// <param name="dst">Destination image</param>
/// <param name="QuantFwdTable">Forward quantization tables for JPEG encoding created using QuantInvTableInit()</param>
/// <param name="oSizeRoi">Roi size (in macro blocks?).</param>
public static void DCTQuantFwd8x8LS(NPPImage_8uC1 src, NPPImage_16sC1 dst, CudaDeviceVariable<ushort> QuantFwdTable, NppiSize oSizeRoi)
{
NppStatus status;
status = NPPNativeMethods.NPPi.ImageCompression.nppiDCTQuantFwd8x8LS_JPEG_8u16s_C1R(src.DevicePointer, src.Pitch, dst.DevicePointer, dst.Pitch, QuantFwdTable.DevicePointer, oSizeRoi);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiDCTQuantFwd8x8LS_JPEG_8u16s_C1R", status));
NPPException.CheckNppStatus(status, null);
}
开发者ID:furusdara,项目名称:cuda,代码行数:16,代码来源:JPEGCompression.cs
示例2: Init
protected override void Init()
{
var kernelFileName = KernelFile;
var initKernel = Ctx.LoadKernel(kernelFileName, "generateData");
B = new CudaDeviceVariable<double>(DimensionsCount);
M = new CudaDeviceVariable<double>(DimensionsCount * DimensionsCount);
Xopt = new CudaDeviceVariable<double>(DimensionsCount);
var d_fopt = new CudaDeviceVariable<double>(1);
long rseed = FunctionNumber + 10000 * InstanceNumber;
initKernel.Run(
DimensionsCount,
rseed,
FunctionNumber,
InstanceNumber,
M.DevicePointer,
B.DevicePointer,
Xopt.DevicePointer,
d_fopt.DevicePointer);
double[] fopt_arr = d_fopt;
Fopt = fopt_arr[0];
}
开发者ID:trojkac,项目名称:effective_pso,代码行数:26,代码来源:GriewankRosenbrockAlgorithm.cs
示例3: CudaIntersectionDevice
public CudaIntersectionDevice(RayEngineScene scene, NVContext ctx)
: base(scene)
{
wallclock = new Stopwatch();
this.todoRayBuffers = new ConcurrentQueue<Tuple<int, RayBuffer>>();
this.doneRayBuffers = new List<ConcurrentQueue<RayBuffer>>() { { new ConcurrentQueue<RayBuffer>() } };
this.started = false;
if (ctx != null)
{
this.cudaContext = ctx;
}
else
{
this.cudaContext = new NVContext() { Context = new CudaContext(CudaContext.GetMaxGflopsDeviceId()) };
}
using (var sr = new StreamReader(@"G:\Git\RayDen\CudaMegaRay\x64\Release\kernel.cu.ptx"))
{
intersectKernel = cudaContext.Context.LoadKernelPTX(sr.BaseStream, "IntersectLBvh");
}
this.rays = new CudaDeviceVariable<RayData>(RayBuffer.RayBufferSize);
this.hits = new CudaDeviceVariable<RayHit>(RayBuffer.RayBufferSize);
verts = scene.Vertices.ToArray();
//scene.Triangles.Select(i => i.GetInfo()).ToArray();
var ti = scene.Triangles.Select(i => i.GetInfo()).ToArray();
var da = new BvhDataAdapter(scene);
var treeData = da.GetMpData();
bvh = treeData;
trianglesCount = ti.Length;
tris = ti;
nodesCount = treeData.Length;
Tracer.TraceLine("BVH Data Size {0:F3} MBytes", (treeData.Length * 32f) / (1024f * 1024f));
}
开发者ID:HungryBear,项目名称:rayden,代码行数:35,代码来源:CudaIntersectionDevice.cs
示例4: Init
protected override void Init()
{
var kernelFileName = KernelFile;
var initKernel = Ctx.LoadKernel(kernelFileName, "generateData");
Xopt = new CudaDeviceVariable<double>(DimensionsCount);
var d_fopt = new CudaDeviceVariable<double>(1);
long rseed = FunctionNumber + 10000 * InstanceNumber;
double[] host_minus_ones = new double[DimensionsCount];
for (int i = 0; i < DimensionsCount; i++)
{
host_minus_ones[i] = -1;
}
MinusOnes = host_minus_ones;
Factor = Math.Max(1.0, Math.Sqrt(DimensionsCount)/8.0);
initKernel.Run(
DimensionsCount,
rseed,
FunctionNumber,
InstanceNumber,
Xopt.DevicePointer,
d_fopt.DevicePointer);
double[] fopt_arr = d_fopt;
Fopt = fopt_arr[0];
}
开发者ID:trojkac,项目名称:effective_pso,代码行数:33,代码来源:RosenbrockAlgorithm.cs
示例5: Backward
public void Backward(CudnnPoolingDescriptor pooling, CudnnTensorDescriptor srcTensor, float[] srcData, CudnnTensorDescriptor srcDiffTensor, float[] srcDiffData,
CudnnTensorDescriptor destTensor, float[] destData, CudnnTensorDescriptor destDiffTensor, float[] destDiffData)
{
Contract.Requires(pooling != null);
Contract.Requires(srcTensor != null);
Contract.Requires(srcData != null);
Contract.Requires(destTensor != null);
Contract.Requires(destData != null);
Contract.Requires(srcDiffTensor != null);
Contract.Requires(srcDiffData != null);
Contract.Requires(destDiffTensor != null);
Contract.Requires(destDiffData != null);
ThrowIfNotInitialized();
CheckIfCompatible(CudnnType.Float, srcTensor, srcDiffTensor, destTensor, destDiffTensor);
using (var srcDataGpu = new CudaDeviceVariable<float>(srcData.Length))
using (var srcDiffDataGpu = new CudaDeviceVariable<float>(srcDiffData.Length))
using (var destDataGpu = new CudaDeviceVariable<float>(destData.Length))
using (var destDiffDataGpu = new CudaDeviceVariable<float>(destDiffData.Length))
{
srcDataGpu.CopyToDevice(srcData);
srcDiffDataGpu.CopyToDevice(srcDiffData);
destDataGpu.CopyToDevice(destData);
Invoke(() => CudnnNativeMethods.cudnnPoolingBackward(handle, pooling.Handle,
srcTensor.Handle, srcDataGpu.DevicePointer, srcDiffTensor.Handle, srcDiffDataGpu.DevicePointer,
destTensor.Handle, destDataGpu.DevicePointer, destDiffTensor.Handle, destDiffDataGpu.DevicePointer));
destDiffDataGpu.CopyToHost(destDiffData);
}
}
开发者ID:redknightlois,项目名称:cudalearn,代码行数:31,代码来源:CudnnContext.Pooling.cs
示例6: launchConfig
////////////////////////////////////////////////////////////////////////////////
// Occupancy-based launch configurator
//
// The launch configurator, cudaOccupancyMaxPotentialBlockSize and
// cudaOccupancyMaxPotentialBlockSizeVariableSMem, suggests a block
// size that achieves the best theoretical occupancy. It also returns
// the minimum number of blocks needed to achieve the occupancy on the
// whole device.
//
// This launch configurator is purely occupancy-based. It doesn't
// translate directly to performance, but the suggestion should
// nevertheless be a good starting point for further optimizations.
//
// This function configures the launch based on the "automatic"
// argument, records the runtime, and reports occupancy and runtime.
////////////////////////////////////////////////////////////////////////////////
static int launchConfig(CudaDeviceVariable<int> array, int arrayCount, bool automatic)
{
int blockSize = 0;
int minGridSize = 0;
int gridSize;
SizeT dynamicSMemUsage = 0;
float elapsedTime;
double potentialOccupancy;
CudaOccupancy.cudaOccDeviceState state = new CudaOccupancy.cudaOccDeviceState();
state.cacheConfig = CudaOccupancy.cudaOccCacheConfig.PreferNone;
if (automatic)
{
CudaOccupancy.cudaOccMaxPotentialOccupancyBlockSize(ref minGridSize, ref blockSize, new CudaOccupancy.cudaOccDeviceProp(0), new CudaOccupancy.cudaOccFuncAttributes(kernel), state, dynamicSMemUsage);
Console.WriteLine("Suggested block size: {0}", blockSize);
Console.WriteLine("Minimum grid size for maximum occupancy: {0}", minGridSize);
}
else
{
// This block size is too small. Given limited number of
// active blocks per multiprocessor, the number of active
// threads will be limited, and thus unable to achieve maximum
// occupancy.
//
blockSize = manualBlockSize;
}
// Round up
//
gridSize = (arrayCount + blockSize - 1) / blockSize;
// Launch and profile
//
kernel.GridDimensions = gridSize;
kernel.BlockDimensions = blockSize;
elapsedTime = kernel.Run(array.DevicePointer, arrayCount);
// Calculate occupancy
//
potentialOccupancy = reportPotentialOccupancy(blockSize, dynamicSMemUsage);
Console.WriteLine("Potential occupancy: {0}%", potentialOccupancy * 100);
// Report elapsed time
//
Console.WriteLine("Elapsed time: {0}ms", elapsedTime * 100);
return 0;
}
开发者ID:kunzmi,项目名称:managedCuda,代码行数:69,代码来源:Program.cs
示例7: BackwardBias
public void BackwardBias(CudnnTensorDescriptor srcTensor, CudaDeviceVariable<double> srcData, CudnnTensorDescriptor destTensor, CudaDeviceVariable<double> destData, CudnnAccumulateResult accumulate)
{
Contract.Requires(srcTensor != null);
Contract.Requires(srcData != null);
Contract.Requires(destTensor != null);
Contract.Requires(destData != null);
ThrowIfNotInitialized();
CheckIfCompatible(CudnnType.Double, srcTensor, destTensor);
Invoke(() => CudnnNativeMethods.cudnnConvolutionBackwardBias(handle, srcTensor.Handle, srcData.DevicePointer, destTensor.Handle, destData.DevicePointer, accumulate));
}
开发者ID:redknightlois,项目名称:cudalearn,代码行数:12,代码来源:CudnnContext.Convolution.cs
示例8: BackwardData
public void BackwardData(CudnnFilterDescriptor filter, CudaDeviceVariable<float> filterData, CudnnTensorDescriptor diffTensor, CudaDeviceVariable<float> diffData, CudnnConvolutionDescriptor convolution, CudnnTensorDescriptor gradient, CudaDeviceVariable<float> gradientData, CudnnAccumulateResult accumulate)
{
Contract.Requires(filter != null);
Contract.Requires(filterData != null);
Contract.Requires(diffTensor != null);
Contract.Requires(diffData != null);
Contract.Requires(convolution != null);
Contract.Requires(gradient != null);
Contract.Requires(gradientData != null);
ThrowIfNotInitialized();
CheckIfCompatible(CudnnType.Float, filter, diffTensor, gradient);
Invoke(() => CudnnNativeMethods.cudnnConvolutionBackwardData(handle, filter.Handle, filterData.DevicePointer, diffTensor.Handle, diffData.DevicePointer, convolution.Handle, gradient.Handle, gradientData.DevicePointer, accumulate));
}
开发者ID:redknightlois,项目名称:cudalearn,代码行数:15,代码来源:CudnnContext.Convolution.cs
示例9: GraphCut4
/// <summary>
///
/// </summary>
/// <param name="size">Graph size</param>
public GraphCut4(NppiSize size)
{
_size = size;
int bufferSize = 0;
status = NPPNativeMethods.NPPi.ImageLabeling.nppiGraphcutGetSize(_size, ref bufferSize);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGraphcutGetSize", status));
NPPException.CheckNppStatus(status, this);
_buffer = new CudaDeviceVariable<byte>(bufferSize);
_state = new NppiGraphcutState();
status = NPPNativeMethods.NPPi.ImageLabeling.nppiGraphcutInitAlloc(_size, ref _state, _buffer.DevicePointer);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGraphcutInitAlloc", status));
NPPException.CheckNppStatus(status, this);
}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:19,代码来源:GraphCut.cs
示例10: Run
public void Run(MatOperation operation, CudaDeviceVariable<float> A, int ACount, int AColumnHint, CudaDeviceVariable<float> B, int BCount, int BColumnHint, CudaDeviceVariable<float> Result, int ResultCount, int ResultColumnHint, float beta = 1.0f)
{
Result.Memset(BitConverter.ToUInt32(BitConverter.GetBytes(0.0f), 0));
switch (operation)
{
case MatOperation.Multiplication: // vectors/matrices have to be always in the correct dimesions!
if (BCount > 1 && ACount > 1 && BColumnHint == 1 && ACount / AColumnHint > 1 && BCount / BColumnHint == AColumnHint) //. A*vecB
{
MyCublasFactory.Instance.Gemv(Operation.Transpose, // transpose beacuase it does Ax row wise if x is a row vector :D
AColumnHint, ACount / AColumnHint, 1.0f,
A, AColumnHint,
B, 1,
beta, Result, 1);
}
else if (ACount > 1 && BCount > 1 && ACount / AColumnHint == 1 && BColumnHint > 1 && BCount / BColumnHint == AColumnHint) // vecA*B
{
MyCublasFactory.Instance.Gemv(Operation.NonTranspose, // transpose beacuase it does Ax row wise if x is a row vector :D
BColumnHint, BCount / BColumnHint, 1.0f,
B, BColumnHint,
A, 1,
beta, Result, 1);
}
else if (ACount / AColumnHint == 1 && BColumnHint == 1 && ACount > 1 && BCount > 1) //. trans(vecA) * vecB
{
Run(MatOperation.DotProd, A, ACount, AColumnHint, B, BCount, BColumnHint, Result, ResultCount, ResultColumnHint, beta);
}
else if (ACount != 1 || BCount != 1)// A*B matrix multiplication
{
MyCublasFactory.Instance.Gemm(Operation.NonTranspose, Operation.NonTranspose,
ACount / AColumnHint, BColumnHint, AColumnHint, 1.0f,
A, ACount / AColumnHint,
B, BCount / BColumnHint,
beta, Result, ResultColumnHint);
}
break;
case MatOperation.DotProd:
MyCublasFactory.Instance.Gemv(Operation.Transpose, // transpose beacuase it does Ax row wise if x is a row vector :D
ACount, 1, 1.0f,
A, ACount,
B, 1,
beta, Result, 1);
break;
default:
MyLog.Writer.WriteLine(MyLogLevel.ERROR, "Trying to run cublas for undefined MatOperation");
break;
}
}
开发者ID:Jlaird,项目名称:BrainSimulator,代码行数:48,代码来源:MyMatrixCublasOps.cs
示例11: GenerateUniformArray
public CudaArray3D GenerateUniformArray(int width, int height, int depth)
{
int count = width * height * depth;
CudaDeviceVariable<float> randomVariable = new CudaDeviceVariable<float>(count);
CudaArray3D randomArray = new CudaArray3D(CUArrayFormat.Float, width, height, depth, CudaArray3DNumChannels.One, CUDAArray3DFlags.None);
randomDevice.SetPseudoRandomGeneratorSeed((ulong)DateTime.Now.Ticks);
randomDevice.GenerateUniform32(randomVariable.DevicePointer, count);
randomArray.CopyFromDeviceToThis(randomVariable.DevicePointer, sizeof(float));
randomVariable.Dispose();
return randomArray;
}
开发者ID:barograf,项目名称:VoxelTerrain,代码行数:16,代码来源:CUDANoiseCube.cs
示例12: ActivationBackward
/* Function to perform backward activation */
public void ActivationBackward(cudnnActivationMode mode,
float alpha,
TensorDescriptor srcDesc,
CudaDeviceVariable<float> srcData,
TensorDescriptor srcDiffDesc,
CudaDeviceVariable<float> srcDiffData,
TensorDescriptor destDesc,
CudaDeviceVariable<float> destData,
float beta,
TensorDescriptor destDiffDesc,
CudaDeviceVariable<float> destDiffData
)
{
res = CudaDNNNativeMethods.cudnnActivationBackward(_handle, mode, ref alpha, srcDesc.Desc, srcData.DevicePointer, srcDiffDesc.Desc, srcDiffData.DevicePointer, destDesc.Desc, destData.DevicePointer, ref beta, destDiffDesc.Desc, destDiffData.DevicePointer);
Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnActivationForward", res));
if (res != cudnnStatus.Success) throw new CudaDNNException(res);
}
开发者ID:MutterOberin,项目名称:managedCuda,代码行数:18,代码来源:CudaDNNContext.cs
示例13: Init
protected override void Init()
{
var kernelFileName = KernelFile;
var initKernel = Ctx.LoadKernel(kernelFileName, "generateData");
Rotation2 = new CudaDeviceVariable<double>(DimensionsCount * DimensionsCount);
Rotation1 = new CudaDeviceVariable<double>(DimensionsCount * DimensionsCount);
Xopt = new CudaDeviceVariable<double>(DimensionsCount);
long rseed = FunctionNumber + 10000 * InstanceNumber;
initKernel.Run(
DimensionsCount,
rseed,
Rotation1.DevicePointer,
Rotation2.DevicePointer,
Xopt.DevicePointer);
}
开发者ID:trojkac,项目名称:effective_pso,代码行数:17,代码来源:LunacekBiRastriginAlgorithm.cs
示例14: DrawStringFromGPUMem
public static void DrawStringFromGPUMem(CudaDeviceVariable<float> inString, int x, int y, uint bgColor, uint fgColor, CUdeviceptr image, int imageWidth, int imageHeight, int stringOffset, int stringLen)
{
MyCudaKernel m_drawDigitKernel = MyKernelFactory.Instance.Kernel(MyKernelFactory.Instance.DevCount - 1, @"Observers\DrawStringKernel");
CudaDeviceVariable<float> characters = MyMemoryManager.Instance.GetGlobalVariable<float>("CHARACTERS_TEXTURE", MyKernelFactory.Instance.DevCount - 1, LoadDigits);
//MyKernelFactory.Instance.Synchronize();
m_drawDigitKernel.SetConstantVariable("D_BG_COLOR", bgColor);
m_drawDigitKernel.SetConstantVariable("D_FG_COLOR", fgColor);
m_drawDigitKernel.SetConstantVariable("D_IMAGE_WIDTH", imageWidth);
m_drawDigitKernel.SetConstantVariable("D_IMAGE_HEIGHT", imageHeight);
m_drawDigitKernel.SetConstantVariable("D_DIGIT_WIDTH", CharacterWidth);
m_drawDigitKernel.SetConstantVariable("D_DIGIT_SIZE", CharacterSize);
m_drawDigitKernel.SetConstantVariable("D_DIGITMAP_NBCHARS", CharacterMapNbChars);
m_drawDigitKernel.SetupExecution(CharacterSize * stringLen);
m_drawDigitKernel.Run(image, characters.DevicePointer, x, y, inString.DevicePointer + sizeof(float) * stringOffset, stringLen);
}
开发者ID:steuerj,项目名称:BrainSimulator,代码行数:18,代码来源:MyTextDrawingOps.cs
示例15: Backward
public void Backward(CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode mode,
CudnnTensorDescriptor srcTensor, CudaDeviceVariable<double> srcData, CudnnTensorDescriptor srcDiffTensor, CudaDeviceVariable<double> srcDiffData,
CudnnTensorDescriptor destDiffTensor, CudaDeviceVariable<double> destDiffData)
{
Contract.Requires(srcTensor != null);
Contract.Requires(srcData != null);
Contract.Requires(srcDiffTensor != null);
Contract.Requires(srcDiffData != null);
Contract.Requires(destDiffTensor != null);
Contract.Requires(destDiffData != null);
ThrowIfNotInitialized();
CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destDiffTensor);
Invoke(() => CudnnNativeMethods.cudnnSoftmaxBackward(handle, algorithm, mode,
srcTensor.Handle, srcData.DevicePointer, srcDiffTensor.Handle, srcDiffData.DevicePointer,
destDiffTensor.Handle, destDiffData.DevicePointer));
}
开发者ID:redknightlois,项目名称:cudalearn,代码行数:18,代码来源:CudnnContext.Softmax.cs
示例16: Test
static void Test(byte[] ptxFile)
{
const int size = 16;
var context = new CudaContext();
var kernel = context.LoadKernelPTX(ptxFile, "kernel");
var memory = context.AllocateMemory(4 * size);
var gpuMemory = new CudaDeviceVariable<int>(memory);
var cpuMemory = new int[size];
for (var i = 0; i < size; i++)
cpuMemory[i] = i - 2;
gpuMemory.CopyToDevice(cpuMemory);
kernel.BlockDimensions = 4;
kernel.GridDimensions = 4;
kernel.Run(memory);
gpuMemory.CopyToHost(cpuMemory);
for (var i = 0; i < size; i++)
Console.WriteLine("{0} = {1}", i, cpuMemory[i]);
}
开发者ID:shaunstanislaus,项目名称:CudaSharp,代码行数:18,代码来源:Program.cs
示例17: Backward
public void Backward(CudnnActivationMode mode, CudnnTensorDescriptor srcTensor, CudaDeviceVariable<float> srcData, CudnnTensorDescriptor srcDiffTensor, CudaDeviceVariable<float> srcDiffData,
CudnnTensorDescriptor destTensor, CudaDeviceVariable<float> destData, CudnnTensorDescriptor destDiffTensor, CudaDeviceVariable<float> destDiffData)
{
Contract.Requires(srcTensor != null);
Contract.Requires(srcData != null);
Contract.Requires(destTensor != null);
Contract.Requires(destData != null);
Contract.Requires(srcDiffTensor != null);
Contract.Requires(srcDiffData != null);
Contract.Requires(destDiffTensor != null);
Contract.Requires(destDiffData != null);
ThrowIfNotInitialized();
CheckIfCompatible(CudnnType.Float, srcTensor, srcDiffTensor, destTensor, destDiffTensor);
Invoke(() => CudnnNativeMethods.cudnnActivationBackward(handle, mode,
srcTensor.Handle, srcData.DevicePointer, srcDiffTensor.Handle, srcDiffData.DevicePointer,
destTensor.Handle, destData.DevicePointer, destDiffTensor.Handle, destDiffData.DevicePointer));
}
开发者ID:redknightlois,项目名称:cudalearn,代码行数:19,代码来源:CudnnContext.Activation.cs
示例18: DadeCudaIntersectionDevice
public DadeCudaIntersectionDevice(RayEngineScene scene, NVContext ctx)
: base(scene)
{
this.scene = scene;
wallclock = new Stopwatch();
this.todoRayBuffers = new InputRayBufferCollection();
this.doneRayBuffers = new OutputRayBufferCollection();
this.started = false;
if (ctx != null)
{
this.cudaContext = ctx;
}
else
{
this.cudaContext = new NVContext() { Context = new CudaContext(CudaContext.GetMaxGflopsDeviceId()) };
}
using (var sr = new StreamReader(@"G:\Git\RayDen\CudaMegaRay\x64\Release\Intersection.cu.ptx"))
{
intersectKernel = cudaContext.Context.LoadKernelPTX(sr.BaseStream, "Intersect");
}
this.rays = new CudaDeviceVariable<RayData>(RayBuffer.RayBufferSize);
this.hits = new CudaDeviceVariable<RayHit>(RayBuffer.RayBufferSize);
verts = scene.Vertices.ToArray();
tris=scene.Triangles.Select(i => i.GetInfo()).ToArray();
if (GlobalConfiguration.Instance.UseSceneCaching && scene.Cache != null)
{
bvh = scene.Cache.BvhData;
nodesCount = scene.Cache.BvhData.Length;
}
else
{
var da = new BvhDataAdapter(scene);
var treeData = da.BuildData();
bvh = treeData;
nodesCount = treeData.Length;
}
Tracer.TraceLine("BVH Data Size {0:F3} MBytes", (nodesCount * 32f) / (1024f * 1024f));
}
开发者ID:HungryBear,项目名称:rayden,代码行数:42,代码来源:DadeCudaIntersectionDevice.cs
示例19: Init
protected override void Init()
{
var kernelFileName = KernelFile;
var initKernel = Ctx.LoadKernel(kernelFileName, "generateData");
initKernel.BlockDimensions = 1;
initKernel.GridDimensions = 1;
Rotation = new CudaDeviceVariable<double>(DimensionsCount * DimensionsCount);
PeakValues = new CudaDeviceVariable<double>(PeaksCount);
XLocal = new CudaDeviceVariable<double>(DimensionsCount * PeaksCount);
ArrScales = new CudaDeviceVariable<double>(DimensionsCount * PeaksCount);
int rseed = FunctionNumber + 10000 * InstanceNumber;
initKernel.Run(
DimensionsCount,
rseed,
Rotation.DevicePointer,
PeaksCount,
PeakValues.DevicePointer,
XLocal.DevicePointer,
ArrScales.DevicePointer);
}
开发者ID:trojkac,项目名称:effective_pso,代码行数:22,代码来源:GallagherAlgorithm.cs
示例20: Init
protected override void Init()
{
var kernelFileName = KernelFile;
var initKernel = Ctx.LoadKernel(kernelFileName, "generateData");
Xopt = new CudaDeviceVariable<double>(DimensionsCount);
M = new CudaDeviceVariable<double>(DimensionsCount * DimensionsCount);
B = new CudaDeviceVariable<double>(DimensionsCount);
var d_fopt = new CudaDeviceVariable<double>(1);
long rseed = FunctionNumber + 10000 * InstanceNumber;
double[] h_ak = new double[12];
double[] h_bk = new double[12];
for (int i = 0; i < 12; i++)
{
h_ak[i] = Math.Pow(0.5, i);
h_bk[i] = Math.Pow(3.0, i);
F0 += h_ak[i]*Math.Cos(Math.PI*h_bk[i]);
}
Ak = h_ak;
Bk = h_bk;
initKernel.Run(
DimensionsCount,
rseed,
FunctionNumber,
InstanceNumber,
M.DevicePointer,
B.DevicePointer,
Xopt.DevicePointer,
d_fopt.DevicePointer);
double[] fopt_arr = d_fopt;
Fopt = fopt_arr[0];
}
开发者ID:trojkac,项目名称:effective_pso,代码行数:39,代码来源:WeierstrassAlgorithm.cs
注:本文中的CudaDeviceVariable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论