Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GpuArray sort operation #488

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ gpuarray_collectives_cuda_nccl.c
gpuarray_buffer_opencl.c
gpuarray_blas_opencl_clblas.c
gpuarray_blas_opencl_clblast.c
gpuarray_sort.c
)

check_function_exists(strlcat HAVE_STRL)
Expand Down Expand Up @@ -126,6 +127,7 @@ set(headers
gpuarray/kernel.h
gpuarray/types.h
gpuarray/util.h
gpuarray/sort.h
)

install(FILES ${headers} DESTINATION include/gpuarray)
Expand Down
64 changes: 64 additions & 0 deletions src/gpuarray/sort.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef GPUARRAY_SORT_H
#define GPUARRAY_SORT_H
/** \file sort.h
* \brief Sort operations generator.
*/

#include <gpuarray/buffer.h>
#include <gpuarray/array.h>
#include <gpuarray/kernel.h>


#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFUSE_EMACS
}
#endif

#define SHARED_SIZE_LIMIT 1024U
#define SAMPLE_STRIDE 128
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't expose this in a public header


typedef struct _GpuSortData {
GpuArray BufKey;
GpuArray BufArg;
GpuArray d_RanksA;
GpuArray d_RanksB;
GpuArray d_LimitsA;
GpuArray d_LimitsB;
} GpuSortData;

typedef struct _GpuSortConfig {
unsigned int dims;
unsigned int Nfloor;
int Nleft;
unsigned int sortDirFlg;
unsigned int argSortFlg;
int typecodeKey;
size_t typesizeKey;
int typecodeArg;
size_t typesizeArg;
} GpuSortConfig;

typedef struct _GpuSortBuffers {
GpuArray BufKey;
GpuArray BufArg;
} GpuSortBuff;

typedef struct _GpuSortKernels {
GpuKernel k_bitonic;
GpuKernel k_ranks;
GpuKernel k_ranks_idxs;
GpuKernel k_merge;
GpuKernel k_merge_global;
} GpuSortKernels;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to hide those structures also.



int GpuArray_sort(GpuArray *r, GpuArray *a, unsigned int sortDir, GpuArray *dstArg);


#ifdef __cplusplus
}
#endif

#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline at the end

Loading