GLS.CUDAParallelPrimitives.pas 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // This unit is part of the GLScene Engine, http://glscene.org
  3. //
  4. // -------------------------------------------------------------
  5. // cuDPP -- CUDA Data Parallel Primitives library
  6. // -------------------------------------------------------------
  7. // $Revision: 4567 $
  8. // $Date: 2020-05-17
  9. // -------------------------------------------------------------
  10. // This source code is distributed under the terms of license.txt in
  11. // the root directory of this source distribution.
  12. // -------------------------------------------------------------
  13. unit GLS.CUDAParallelPrimitives;
  14. (* CUDA Parallel Primitives *)
  15. interface
  16. // uses OpenCL;
  17. const
  18. CUDPPDLL = 'cudpp32.dll';
  19. CUDPP_INVALID_HANDLE = $C0DABAD1;
  20. type
  21. TCUDPPResult = (
  22. CUDPP_SUCCESS, // No error.
  23. CUDPP_ERROR_INVALID_HANDLE, // Specified handle (for example,
  24. // to a plan) is invalid.
  25. CUDPP_ERROR_ILLEGAL_CONFIGURATION, // Specified configuration is
  26. // illegal. For example, an
  27. // invalid or illogical
  28. // combination of options.
  29. CUDPP_ERROR_UNKNOWN // Unknown or untraceable error.
  30. );
  31. TCUDPPOption = (
  32. CUDPP_OPTION_FORWARD, // Algorithms operate forward:
  33. // from start to end of input
  34. // array
  35. CUDPP_OPTION_BACKWARD, // Algorithms operate backward:
  36. // from end to start of array
  37. CUDPP_OPTION_EXCLUSIVE, // Exclusive (for scans) - scan
  38. // includes all elements up to (but
  39. // not including) the current
  40. // element
  41. CUDPP_OPTION_INCLUSIVE, // Inclusive (for scans) - scan
  42. // includes all elements up to and
  43. // including the current element
  44. CUDPP_OPTION_CTA_LOCAL, // Algorithm performed only on
  45. // the CTAs (blocks) with no
  46. // communication between blocks.
  47. // @todo Currently ignored.
  48. CUDPP_OPTION_KEYS_ONLY, // No associated value to a key
  49. // (for global radix sort)
  50. CUDPP_OPTION_KEY_VALUE_PAIRS // Each key has an associated value
  51. );
  52. TCUDPPDatatype = (
  53. CUDPP_CHAR, // Character type (C char)
  54. CUDPP_UCHAR, // Unsigned character (byte) type (C unsigned char)
  55. CUDPP_INT, // Integer type (C int)
  56. CUDPP_UINT, // Unsigned integer type (C unsigned int)
  57. CUDPP_FLOAT // Float type (C float)
  58. );
  59. TCUDPPOperator = (
  60. CUDPP_ADD, // Addition of two operands
  61. CUDPP_MULTIPLY, // Multiplication of two operands
  62. CUDPP_MIN, // Minimum of two operands
  63. CUDPP_MAX // Maximum of two operands
  64. );
  65. TCUDPPAlgorithm = (
  66. CUDPP_SCAN,
  67. CUDPP_SEGMENTED_SCAN,
  68. CUDPP_COMPACT,
  69. CUDPP_REDUCE,
  70. CUDPP_SORT_RADIX,
  71. CUDPP_SPMVMULT, // Sparse matrix-dense vector multiplication
  72. CUDPP_RAND_MD5, // Pseudo Random Number Generator using MD5 hash algorithm
  73. CUDPP_ALGORITHM_INVALID // Placeholder at end of enum
  74. );
  75. TCUDPPConfiguration = record
  76. algorithm: TCUDPPAlgorithm; // The algorithm to be used
  77. op: TCUDPPOperator; // The numerical operator to be applied
  78. datatype: TCUDPPDatatype; // The datatype of the input arrays
  79. options: TCUDPPoption; // Options to configure the algorithm
  80. end;
  81. TCUDPPHandle = NativeUInt;
  82. // Plan allocation (for scan, sort, and compact)
  83. function cudppPlan(var planHandle: TCUDPPHandle;
  84. config: TCUDPPConfiguration;
  85. n: NativeUInt;
  86. rows: NativeUInt;
  87. rowPitch: NativeUInt): TCUDPPResult;
  88. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  89. function cudppDestroyPlan(plan: TCUDPPHandle): TCUDPPResult;
  90. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  91. // Scan and sort algorithms
  92. function cudppScan(planHandle: TCUDPPHandle;
  93. var d_out;
  94. var d_in,
  95. numElements: NativeUInt): TCUDPPResult;
  96. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  97. function cudppMultiScan(planHandle: TCUDPPHandle;
  98. var d_out;
  99. var d_in;
  100. numElements: NativeUInt;
  101. numRows: NativeUInt): TCUDPPResult;
  102. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  103. function cudppSegmentedScan(planHandle: TCUDPPHandle;
  104. var d_out;
  105. var d_idata;
  106. const d_iflags: PCardinal;
  107. numElements: NativeUInt): TCUDPPResult;
  108. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  109. function cudppCompact(planHandle: TCUDPPHandle;
  110. var d_out;
  111. var d_numValidElements: NativeUInt;
  112. var d_in;
  113. const d_isValid: PCardinal;
  114. numElements: NativeUInt): TCUDPPResult;
  115. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  116. function cudppSort(planHandle: TCUDPPHandle;
  117. var d_keys;
  118. var d_values;
  119. keybits: Integer;
  120. numElements: NativeUInt): TCUDPPResult;
  121. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  122. // Sparse matrix allocation
  123. function cudppSparseMatrix(var sparseMatrixHandle: TCUDPPHandle;
  124. config: TCUDPPConfiguration;
  125. n: NativeUInt;
  126. rows: NativeUInt;
  127. var A;
  128. const h_rowIndices: PCardinal;
  129. const h_indices: PCardinal): TCUDPPResult;
  130. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  131. function cudppDestroySparseMatrix(sparseMatrixHandle: TCUDPPHandle):
  132. TCUDPPResult;
  133. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  134. // Sparse matrix-vector algorithms
  135. function cudppSparseMatrixVectorMultiply(sparseMatrixHandle: TCUDPPHandle;
  136. var d_y;
  137. var d_x): TCUDPPResult;
  138. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  139. // random number generation algorithms
  140. function cudppRand(planHandle: TCUDPPHandle;
  141. var d_out;
  142. numElements: NativeUInt): TCUDPPResult;
  143. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  144. function cudppRandSeed(const planHandle: TCUDPPHandle;
  145. seed: Cardinal): TCUDPPResult;
  146. {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}external CUDPPDLL;
  147. implementation
  148. end.