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

Add Python translation support for pyccel.cuda.host_empty and pyccel.cuda.device_empty #58

Open
5 tasks
EmilyBourne opened this issue Jun 13, 2024 · 0 comments
Labels
blocked enhancement New feature or request

Comments

@EmilyBourne
Copy link
Member

Relevant Discussion

#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:

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])

Additional Information

This issue is blocked by #56 and #57

@EmilyBourne EmilyBourne added enhancement New feature or request blocked labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant