24 #ifndef TILEDARRAY_EXTERNAL_CUTT_H__INCLUDED
25 #define TILEDARRAY_EXTERNAL_CUTT_H__INCLUDED
27 #include <TiledArray/config.h>
29 #ifdef TILEDARRAY_HAS_CUDA
46 inline void extent_to_col_major(std::vector<int>& extent) {
47 std::reverse(extent.begin(), extent.end());
54 inline void permutation_to_col_major(std::vector<int>& perm) {
55 int size = perm.size();
57 std::vector<int> col_major_perm(size, 0);
59 for (
int input_index = 0; input_index < size; input_index++) {
60 int output_index = perm[input_index];
63 int input_index_col_major = size - input_index - 1;
64 int output_index_col_major = size - output_index - 1;
66 col_major_perm[input_index_col_major] = output_index_col_major;
69 perm.swap(col_major_perm);
82 auto extent = range.
extent();
83 std::vector<int> extent_int(extent.begin(), extent.end());
86 auto perm_inv = perm.
inv();
87 std::vector<int> perm_int(perm_inv.begin(), perm_inv.end());
90 TiledArray::extent_to_col_major(extent_int);
91 TiledArray::permutation_to_col_major(perm_int);
96 status = cuttPlan(&plan, range.
rank(), extent_int.data(), perm_int.data(),
101 status = cuttExecute(plan, inData, outData);
105 status = cuttDestroy(plan);
112 #endif // TILEDARRAY_HAS_CUDA
114 #endif // TILEDARRAY_EXTERNAL_CUTT_H__INCLUDED