forked from inducer/compyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request inducer#4 from nouiz/reorg
Numpy-like C-API interface for easier conversion in a separate header.
- Loading branch information
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This file isn't recommanded. Using it make your code not able to work on OpenCL. | ||
* | ||
* But it allow faster conversion to this new library of existing code | ||
*/ | ||
#include "extension.h" | ||
#ifndef COMPYTE_BUFFER_CUDA_H | ||
#define COMPYTE_BUFFER_CUDA_H | ||
|
||
int PyGpuArray_NDIM(PyGpuArrayObject *arr) { | ||
return arr->ga.nd; | ||
} | ||
size_t *PyGpuArray_DIMS(PyGpuArrayObject *arr) { | ||
return arr->ga.dimensions; | ||
} | ||
|
||
ssize_t *PyGpuArray_STRIDES(PyGpuArrayObject* arr) { | ||
return arr->ga.strides; | ||
} | ||
size_t PyGpuArray_DIM(PyGpuArrayObject* arr, int n) { | ||
return arr->ga.dimensions[n]; | ||
} | ||
ssize_t PyGpuArray_STRIDE(PyGpuArrayObject* arr, int n) { | ||
return arr->ga.strides[n]; | ||
} | ||
//int PyGpuArray_ITEMSIZE(PyGpuArrayObject* arr) | ||
size_t PyGpuArray_SIZE(PyGpuArrayObject* arr) { | ||
size_t size = 1; | ||
for(int i=0; i< arr->ga.nd; i++) { | ||
size *= arr->ga.dimensions[i]; | ||
} | ||
return size; | ||
} | ||
|
||
#endif |