CUDA.ParallelPrimitives.pas 5.1 KB

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