I would like to be able to explicitly allocate memory on the CPU or GPU. After #56 and #57 the Python code that describes this should be working. In this issue we want to add syntactic/semantic. In order to test this we will ensure that we can translate from Python to Python.
Test Code
Provide code which does not currently work but which should do when this issue is fixed:
import pyccel.cuda as cuda
if __name__ == '__main__':
n = 100
a = cuda.host_empty(n)
b = cuda.device_empty(n)
for i in range(n):
a[i] = i
print(a)
Proposed Solution
A class PyccelCudaEmpty should be created in pyccel.ast.cudaext. It should describe the objects cuda.host_empty and cuda.device_empty. The implementation of this type is left to the developer. It will either be similar to NumpyEmpty or may be able to inherit from NumpyEmpty.
A Module should be created to describe pyccel.cuda and should map host_empty and device_empty to this class or to subclasses (subclasses may be useful to ensure the correct prototype).
The class type of a and b will need to be defined. This should be done in a file pyccel.ast.cudatypes. The new type must satisfy the following criteria:
[ ] Inherit from ContainerType
[ ] Have a rank
[ ] Have an order
[ ] Have a memory location (CPU/GPU)
[ ] Have all the methods mentioned in the documentation
The __add__ and __and__ operators should ensure that it is not possible to mix CPU and GPU memory in the same operation (e.g. not possible to do device_array[i] + host_array[i])
Relevant Discussion
https://github.com/pyccel/pyccel-cuda/discussions/55 and discussion in the meeting on 13/6/2024
Describe the feature
I would like to be able to explicitly allocate memory on the CPU or GPU. After #56 and #57 the Python code that describes this should be working. In this issue we want to add syntactic/semantic. In order to test this we will ensure that we can translate from Python to Python.
Test Code
Provide code which does not currently work but which should do when this issue is fixed:
Proposed Solution
A class
PyccelCudaEmpty
should be created inpyccel.ast.cudaext
. It should describe the objectscuda.host_empty
andcuda.device_empty
. The implementation of this type is left to the developer. It will either be similar toNumpyEmpty
or may be able to inherit fromNumpyEmpty
.A
Module
should be created to describepyccel.cuda
and should maphost_empty
anddevice_empty
to this class or to subclasses (subclasses may be useful to ensure the correct prototype).The class type of
a
andb
will need to be defined. This should be done in a filepyccel.ast.cudatypes
. The new type must satisfy the following criteria:ContainerType
The
__add__
and__and__
operators should ensure that it is not possible to mix CPU and GPU memory in the same operation (e.g. not possible to dodevice_array[i] + host_array[i]
)Additional Information
This issue is blocked by #56 and #57