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


C# BasicTypes.CUdeviceptr类代码示例

本文整理汇总了C#中ManagedCuda.BasicTypes.CUdeviceptr的典型用法代码示例。如果您正苦于以下问题:C# CUdeviceptr类的具体用法?C# CUdeviceptr怎么用?C# CUdeviceptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CUdeviceptr类属于ManagedCuda.BasicTypes命名空间,在下文中一共展示了CUdeviceptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawString

        public static void DrawString(string str, int x, int y, uint bgColor, uint fgColor, CUdeviceptr image, int imageWidth, int imageHeight, int maxStringSize = 20)
        {
            // Crop if the string is too long
            if (str.Length > maxStringSize)
                str = str.Substring(0, maxStringSize);

            if (str.Length > 200)
            {
                //__constant__ int D_DIGIT_INDEXES[200];
                throw new ArgumentException("Hardcoded value in DrawDigitsKernel.cs");
            }

            MyCudaKernel m_drawDigitKernel = MyKernelFactory.Instance.Kernel(MyKernelFactory.Instance.DevCount - 1, @"Observers\DrawDigitsKernel");
            CudaDeviceVariable<float> characters = MyMemoryManager.Instance.GetGlobalVariable<float>("CHARACTERS_TEXTURE", MyKernelFactory.Instance.DevCount - 1, LoadDigits);

            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);

            int[] indexes = StringToDigitIndexes(str);
            m_drawDigitKernel.SetConstantVariable("D_DIGIT_INDEXES", indexes);
            m_drawDigitKernel.SetConstantVariable("D_DIGIT_INDEXES_LEN", indexes.Length);

            m_drawDigitKernel.SetupExecution(CharacterSize * indexes.Length);
            m_drawDigitKernel.Run(image, characters.DevicePointer, x, y);
        }
开发者ID:steuerj,项目名称:BrainSimulator,代码行数:30,代码来源:MyTextDrawingOps.cs

示例2: cudnnActivationForward

        public static extern cudnnStatus cudnnActivationForward( cudnnHandle handle,
														  cudnnActivationMode mode,
														  ref float alpha,
														  cudnnTensorDescriptor srcDesc,
														  CUdeviceptr srcData,
														  ref float beta,
														  cudnnTensorDescriptor destDesc,
														  CUdeviceptr destData
														);
开发者ID:furusdara,项目名称:cuda,代码行数:9,代码来源:CudaDNNNativeMethods.cs

示例3: cublasAxpyEx

 public static extern CublasStatus cublasAxpyEx(CudaBlasHandle handle,
                                               int n,
                                               CUdeviceptr alpha, /* host or device pointer */
                                               cudaDataType alphaType,
                                               CUdeviceptr x,
                                               cudaDataType xType,
                                               int incx,
                                               CUdeviceptr y,
                                               cudaDataType yType,
                                               int incy,
                                               cudaDataType executiontype);
开发者ID:kunzmi,项目名称:managedCuda,代码行数:11,代码来源:CudaBlasNativeMethods.cs

示例4: Bind

        public override void Bind(CUdeviceptr firstInput, params CUdeviceptr[] otherInputs)
        {
            if (otherInputs == null)
                otherInputs = new CUdeviceptr[] { firstInput };

            var output = otherInputs[otherInputs.Length - 1];
            m_XORKernel.Run(firstInput, otherInputs[0], output, (int)MyJoin.MyJoinOperation.XOR, m_inputSize);

            for (int i = 1; i < otherInputs.Length - 1; ++i)
                m_XORKernel.Run(otherInputs[i], output, output, (int)MyJoin.MyJoinOperation.XOR, m_inputSize);
        }
开发者ID:Jlaird,项目名称:BrainSimulator,代码行数:11,代码来源:MyXORBinder.cs

示例5: cusparseCbsric02

        public static extern cusparseStatus cusparseCbsric02(cusparseContext handle,
											  cusparseDirection dirA,
											  int mb,
											  int nnzb,
											  cusparseMatDescr descrA,
											  CUdeviceptr bsrVal,
											  CUdeviceptr bsrRowPtr,
											  CUdeviceptr bsrColInd,
											  int blockDim,
											  bsric02Info info,
											  cusparseSolvePolicy policy,
											  CUdeviceptr pBuffer);
开发者ID:kunzmi,项目名称:managedCuda,代码行数:12,代码来源:CudaSparseNativeMethods.cs

示例6: cusparseCbsr2csr

        public static extern cusparseStatus cusparseCbsr2csr(cusparseContext handle,
											cusparseDirection dirA,
											int mb,
											int nb,
											cusparseMatDescr descrA,
											CUdeviceptr bsrValA,
											CUdeviceptr bsrRowPtrA,
											CUdeviceptr bsrColIndA,
											int blockDim,
											cusparseMatDescr descrC,
											CUdeviceptr csrValC,
											CUdeviceptr csrRowPtrC,
											CUdeviceptr csrColIndC);
开发者ID:kunzmi,项目名称:managedCuda,代码行数:13,代码来源:CudaSparseNativeMethods.cs

示例7: cudnnActivationBackward

        public static extern cudnnStatus cudnnActivationBackward( cudnnHandle handle,
                                                           cudnnActivationDescriptor activationDesc,
                                                           ref float alpha,
														   cudnnTensorDescriptor srcDesc,
														   CUdeviceptr srcData,
														   cudnnTensorDescriptor srcDiffDesc,
														   CUdeviceptr srcDiffData,
														   cudnnTensorDescriptor destDesc,
														   CUdeviceptr destData,
														   ref float beta,
														   cudnnTensorDescriptor destDiffDesc,
														   CUdeviceptr destDiffData
														 );
开发者ID:kunzmi,项目名称:managedCuda,代码行数:13,代码来源:CudaDNNNativeMethods.cs

示例8: NPPImage_32sC4

		/// <summary>
		/// Creates a new NPPImage from allocated device ptr.
		/// </summary>
		/// <param name="devPtr">Already allocated device ptr.</param>
		/// <param name="width">Image width in pixels</param>
		/// <param name="height">Image height in pixels</param>
		/// <param name="pitch">Pitch / Line step</param>
		/// <param name="isOwner">If TRUE, devPtr is freed when disposing</param>
		public NPPImage_32sC4(CUdeviceptr devPtr, int width, int height, int pitch, bool isOwner)
		{
			_devPtr = devPtr;
			_devPtrRoi = _devPtr;
			_sizeOriginal.width = width;
			_sizeOriginal.height = height;
			_sizeRoi.width = width;
			_sizeRoi.height = height;
			_pitch = pitch;
			_channels = 4;
			_isOwner = isOwner;
			_typeSize = sizeof(int);
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:21,代码来源:NPPImage_32sC4.cs

示例9: NPPImage_32fcC2

		/// <summary>
		/// Creates a new NPPImage from allocated device ptr.
		/// </summary>
		/// <param name="devPtr">Already allocated device ptr.</param>
		/// <param name="width">Image width in pixels</param>
		/// <param name="height">Image height in pixels</param>
		/// <param name="pitch">Pitch / Line step</param>
		/// <param name="isOwner">If TRUE, devPtr is freed when disposing</param>
		public NPPImage_32fcC2(CUdeviceptr devPtr, int width, int height, int pitch, bool isOwner)
		{
			_devPtr = devPtr;
			_devPtrRoi = _devPtr;
			_sizeOriginal.width = width;
			_sizeOriginal.height = height;
			_sizeRoi.width = width;
			_sizeRoi.height = height;
			_pitch = pitch;
			_channels = 2;
			_isOwner = isOwner;
			_typeSize = Marshal.SizeOf(typeof(Npp32fc));
		}
开发者ID:lvaleriu,项目名称:managedCuda,代码行数:21,代码来源:NPPImage_32fcC2.cs

示例10: cudnnActivationBackward

        public static extern cudnnStatus cudnnActivationBackward( cudnnHandle handle,
														   cudnnActivationMode mode,
														   ref double alpha,
														   cudnnTensorDescriptor srcDesc,
														   CUdeviceptr srcData,
														   cudnnTensorDescriptor srcDiffDesc,
														   CUdeviceptr srcDiffData,
														   cudnnTensorDescriptor destDesc,
														   CUdeviceptr destData,
														   ref double beta,
														   cudnnTensorDescriptor destDiffDesc,
														   CUdeviceptr destDiffData
														 );
开发者ID:furusdara,项目名称:cuda,代码行数:13,代码来源:CudaDNNNativeMethods.cs

示例11: Bind

        void Bind(CUdeviceptr firstInput, IEnumerable<CUdeviceptr> otherInputs, CUdeviceptr output, int method)
        {
            if (otherInputs == null)
                throw new ArgumentNullException("otherInputs");

            var second = otherInputs.FirstOrDefault();

            if (second == null)
                throw new ArgumentException("Nothing to bind with...");

            m_binaryPermKernel.RunAsync(m_stream, firstInput, second, output, method, m_inputSize);

            foreach (var input in otherInputs.Skip(1)) // Exclude the second input
                m_binaryPermKernel.RunAsync(m_stream, input, output, output, method, m_inputSize);
        }
开发者ID:sschocke,项目名称:BrainSimulator,代码行数:15,代码来源:MyPermutationBinder.cs

示例12: Bind

        public override void Bind(CUdeviceptr firstInput, IEnumerable<CUdeviceptr> otherInputs, CUdeviceptr output)
        {
            m_fft.Exec(firstInput, m_tempBlock.GetDevicePtr(m_owner, m_secondFFTOffset));

            foreach (var input in otherInputs)
            {
                m_fft.Exec(input, m_tempBlock.GetDevicePtr(m_owner, m_firstFFTOffset));
                m_mulkernel.RunAsync(
                    m_stream,
                    m_tempBlock.GetDevicePtr(m_owner, m_firstFFTOffset),
                    m_tempBlock.GetDevicePtr(m_owner, m_secondFFTOffset),
                    m_tempBlock.GetDevicePtr(m_owner, m_secondFFTOffset), m_inputSize + 1);
            }

            FinishBinding(output);
        }
开发者ID:sschocke,项目名称:BrainSimulator,代码行数:16,代码来源:MyFourierBinder.cs

示例13: 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

示例14: cudnnDivisiveNormalizationBackward

        public void cudnnDivisiveNormalizationBackward(
									  cudnnDivNormMode mode,
									  float alpha,
									  cudnnTensorDescriptor srcDesc, // same desc for diff, means, temp, temp2
									  CUdeviceptr srcData,
									  CUdeviceptr srcMeansData, // if NULL, means are assumed to be zero
									  CUdeviceptr srcDiffData,
									  CUdeviceptr tempData,
									  CUdeviceptr tempData2,
									  float betaData,
									  cudnnTensorDescriptor destDataDesc, // same desc for dest, means, meansDiff
									  CUdeviceptr destDataDiff, // output data differential
									  CUdeviceptr destMeansDiff // output means differential, can be NULL
			)
        {
            res = CudaDNNNativeMethods.cudnnDivisiveNormalizationBackward(_handle, _desc, mode, ref alpha, srcDesc, srcData, srcMeansData, srcDiffData, tempData, tempData2, ref betaData, destDataDesc, destDataDiff, destMeansDiff);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnDivisiveNormalizationBackward", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
开发者ID:MutterOberin,项目名称:managedCuda,代码行数:19,代码来源:LRNDescriptor.cs

示例15: Bind

        void Bind(CUdeviceptr firstInput, CUdeviceptr[] otherInputs, int method)
        {
            if (otherInputs == null)
                otherInputs = new[] { firstInput };

            var output = otherInputs[otherInputs.Length - 1];

            if (otherInputs.Length <= 2)
            {
                m_binaryPermKernel.Run(firstInput, otherInputs[0], output, method, m_inputSize);
                return;
            }

            m_tempBlock.Host[0] = firstInput;

            for (int i = 1; i < otherInputs.Length; i++)
                m_tempBlock.Host[i] = otherInputs[i - 1];

            m_tempBlock.SafeCopyToDevice(0, otherInputs.Length);
            m_PermKernel.Run(m_tempBlock, m_tempBlock.Count, output, method, m_inputSize);
        }
开发者ID:J-F-B-M,项目名称:BrainSimulator,代码行数:21,代码来源:MyPermutationBinder.cs


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