public void nppsSet_32s_test() { int length = 1024; int value = 75; IntPtr ptr = Npps.nppsMalloc_32s(length); int[] result = new int[length]; GCHandle gcHandle = GCHandle.Alloc(result, GCHandleType.Pinned); IntPtr h_result = Marshal.UnsafeAddrOfPinnedArrayElement(result, 0); UInt64 size = Convert.ToUInt64(sizeof(int) * result.Length); NppStatus status = Npps.nppsSet_32s(value, ptr, length); if (status != NppStatus.NPP_SUCCESS) { Assert.Fail(String.Format("Fail {0}", status.ToString())); } cudaError cudaStatus = CudaRuntimeApi.cudaMemcpy(h_result, ptr, size, cudaMemcpyKind.DeviceToHost); if (cudaStatus != cudaError.cudaSuccess) { Assert.Fail(String.Format("Fail {0}", cudaStatus.ToString())); } for (int i = 0; i < result.Length; i++) { Assert.AreEqual(value, result[i]); } gcHandle.Free(); Npps.nppsFree(ptr); }
internal static string GetErrorMessageFromNppStatus(NppStatus error) { string message = string.Empty; switch (error) { case NppStatus.NotSupportedModeError: break; case NppStatus.InvalidHostPointerError: break; case NppStatus.InvalidDevicePointerError: break; case NppStatus.LUTPaletteBitsizeError: break; case NppStatus.ZCModeNotSupportedError: message = "ZeroCrossing mode not supported."; break; case NppStatus.NotSufficientComputeCapability: break; case NppStatus.TextureBindError: break; case NppStatus.WrongIntersectionRoiError: break; case NppStatus.HaarClassifierPixelMatchError: break; case NppStatus.MemfreeError: break; case NppStatus.MemsetError: break; case NppStatus.MemcpyError: break; case NppStatus.AlignmentError: break; case NppStatus.CudaKernelExecutionError: break; case NppStatus.RoundModeNotSupportedError: message = "Unsupported round mode."; break; case NppStatus.QualityIndexError: message = "Image pixels are constant for quality index."; break; case NppStatus.ResizeNoOperationError: message = "One of the output image dimensions is less than 1 pixel."; break; case NppStatus.OverflowError: message = "Number overflows the upper or lower limit of the data type."; break; case NppStatus.NotEvenStepError: message = "Step value is not pixel multiple."; break; case NppStatus.HistogramNumberOfLevelsError: message = "Number of levels for histogram is less than 2."; break; case NppStatus.LutMumberOfLevelsError: message = "Number of levels for LUT is less than 2."; break; case NppStatus.ChannelOrderError: message = "Wrong order of the destination channels."; break; case NppStatus.ZeroMaskValueError: message = "All values of the mask are zero."; break; case NppStatus.QuadrangleError: message = "The quadrangle is nonconvex or degenerates into triangle, line or point."; break; case NppStatus.RectangleError: message = "Size of the rectangle region is less than or equal to 1."; break; case NppStatus.CoefficientError: message = "Unallowable values of the transformation coefficients."; break; case NppStatus.NumberOfChannelsError: message = "Bad or unsupported number of channels."; break; case NppStatus.ChannelOfInterestError: message = "Channel of interest is not 1, 2, or 3."; break; case NppStatus.DivisorError: message = "Divisor is equal to zero."; break; case NppStatus.CorruptedDataError: message = "Processed data is corrupted."; break; case NppStatus.ChannelError: message = "Illegal channel index."; break; case NppStatus.StrideError: message = "Stride is less than the row length."; break; case NppStatus.AnchorError: message = "Anchor point is outside mask."; break; case NppStatus.MaskSizeError: message = "Lower bound is larger than upper bound."; break; case NppStatus.ResizeFactorError: break; case NppStatus.InterpolationError: break; case NppStatus.MirrorFlipError: break; case NppStatus.Moment00ZeroErro: break; case NppStatus.ThresholdNegativeLevelError: break; case NppStatus.ThresholdError: break; case NppStatus.ContextMatchError: break; case NppStatus.FFTFlagError: break; case NppStatus.FFTOrderError: break; case NppStatus.StepError: message = "Step is less or equal zero."; break; case NppStatus.ScaleRangeError: break; case NppStatus.DataTypeError: break; case NppStatus.OutOfRangeError: break; case NppStatus.DivideByZeroError: break; case NppStatus.MemoryAllocationError: break; case NppStatus.NullPointerError: break; case NppStatus.RangeError: break; case NppStatus.SizeError: break; case NppStatus.BadArgumentError: break; case NppStatus.NoMemoryError: break; case NppStatus.NotImplementedError: break; case NppStatus.Error: break; case NppStatus.ErrorReserved: break; case NppStatus.NoError: message = "Successful operation."; break; //case NppStatus.Success: // break; case NppStatus.NoOperationWarning: message = "Indicates that no operation was performed."; break; case NppStatus.DivideByZeroWarning: message = "Divisor is zero however does not terminate the execution."; break; case NppStatus.AffineQuadIncorrectWarning: message = "Indicates that the quadrangle passed to one of affine warping functions doesn't have necessary properties. First 3 vertices are used, the fourth vertex discarded."; break; case NppStatus.WrongIntersectionRoiWarning: message = "The given ROI has no interestion with either the source or destination ROI. Thus no operation was performed."; break; case NppStatus.WrongIntersectionQuadWarning: message = "The given quadrangle has no intersection with either the source or destination ROI. Thus no operation was performed."; break; case NppStatus.DoubleSizeWarning: message = "Image size isn't multiple of two. Indicates that in case of 422/411/420 sampling the ROI width/height was modified for proper processing."; break; case NppStatus.MisalignedDstRoiWarning: message = "Speed reduction due to uncoalesced memory accesses warning."; break; default: break; } return error.ToString() + ": " + message; }
internal static string GetErrorMessageFromNppStatus(NppStatus error) { string message = string.Empty; switch (error) { case NppStatus.NotSupportedModeError: break; case NppStatus.InvalidHostPointerError: break; case NppStatus.InvalidDevicePointerError: break; case NppStatus.LUTPaletteBitsizeError: break; case NppStatus.ZCModeNotSupportedError: message = "ZeroCrossing mode not supported."; break; case NppStatus.NotSufficientComputeCapability: break; case NppStatus.TextureBindError: break; case NppStatus.WrongIntersectionRoiError: break; case NppStatus.HaarClassifierPixelMatchError: break; case NppStatus.MemfreeError: break; case NppStatus.MemsetError: break; case NppStatus.MemcpyError: break; case NppStatus.AlignmentError: break; case NppStatus.CudaKernelExecutionError: break; case NppStatus.RoundModeNotSupportedError: message = "Unsupported round mode."; break; case NppStatus.QualityIndexError: message = "Image pixels are constant for quality index."; break; case NppStatus.ResizeNoOperationError: message = "One of the output image dimensions is less than 1 pixel."; break; case NppStatus.OverflowError: message = "Number overflows the upper or lower limit of the data type."; break; case NppStatus.NotEvenStepError: message = "Step value is not pixel multiple."; break; case NppStatus.HistogramNumberOfLevelsError: message = "Number of levels for histogram is less than 2."; break; case NppStatus.LutMumberOfLevelsError: message = "Number of levels for LUT is less than 2."; break; case NppStatus.ChannelOrderError: message = "Wrong order of the destination channels."; break; case NppStatus.ZeroMaskValueError: message = "All values of the mask are zero."; break; case NppStatus.QuadrangleError: message = "The quadrangle is nonconvex or degenerates into triangle, line or point."; break; case NppStatus.RectangleError: message = "Size of the rectangle region is less than or equal to 1."; break; case NppStatus.CoefficientError: message = "Unallowable values of the transformation coefficients."; break; case NppStatus.NumberOfChannelsError: message = "Bad or unsupported number of channels."; break; case NppStatus.ChannelOfInterestError: message = "Channel of interest is not 1, 2, or 3."; break; case NppStatus.DivisorError: message = "Divisor is equal to zero."; break; case NppStatus.CorruptedDataError: message = "Processed data is corrupted."; break; case NppStatus.ChannelError: message = "Illegal channel index."; break; case NppStatus.StrideError: message = "Stride is less than the row length."; break; case NppStatus.AnchorError: message = "Anchor point is outside mask."; break; case NppStatus.MaskSizeError: message = "Lower bound is larger than upper bound."; break; case NppStatus.ResizeFactorError: break; case NppStatus.InterpolationError: break; case NppStatus.MirrorFlipError: break; case NppStatus.Moment00ZeroErro: break; case NppStatus.ThresholdNegativeLevelError: break; case NppStatus.ThresholdError: break; case NppStatus.ContextMatchError: break; case NppStatus.FFTFlagError: break; case NppStatus.FFTOrderError: break; case NppStatus.StepError: message = "Step is less or equal zero."; break; case NppStatus.ScaleRangeError: break; case NppStatus.DataTypeError: break; case NppStatus.OutOfRangeError: break; case NppStatus.DivideByZeroError: break; case NppStatus.MemoryAllocationError: break; case NppStatus.NullPointerError: break; case NppStatus.RangeError: break; case NppStatus.SizeError: break; case NppStatus.BadArgumentError: break; case NppStatus.NoMemoryError: break; case NppStatus.NotImplementedError: break; case NppStatus.Error: break; case NppStatus.ErrorReserved: break; case NppStatus.NoError: message = "Successful operation."; break; //case NppStatus.Success: // break; case NppStatus.NoOperationWarning: message = "Indicates that no operation was performed."; break; case NppStatus.DivideByZeroWarning: message = "Divisor is zero however does not terminate the execution."; break; case NppStatus.AffineQuadIncorrectWarning: message = "Indicates that the quadrangle passed to one of affine warping functions doesn't have necessary properties. First 3 vertices are used, the fourth vertex discarded."; break; case NppStatus.WrongIntersectionRoiWarning: message = "The given ROI has no interestion with either the source or destination ROI. Thus no operation was performed."; break; case NppStatus.WrongIntersectionQuadWarning: message = "The given quadrangle has no intersection with either the source or destination ROI. Thus no operation was performed."; break; case NppStatus.DoubleSizeWarning: message = "Image size isn't multiple of two. Indicates that in case of 422/411/420 sampling the ROI width/height was modified for proper processing."; break; case NppStatus.MisalignedDstRoiWarning: message = "Speed reduction due to uncoalesced memory accesses warning."; break; default: break; } return(error.ToString() + ": " + message); }