Skip to content

[Python | GPU] Reduce operation fails code generation on GPU #2240

@FlorianDeconinck

Description

@FlorianDeconinck

Tested only in DaCe v1

The following code should work

import dace
import cupy as cp
import numpy as np

@dace.program
def multidimred(a, b):
    b[:] = np.sum(a, axis=(0, 1))


a = cp.random.rand(2, 2, 6)
b = cp.random.rand(6)
multidimred(a, b)

but it dies in codegen:

  File "/home/fgdeconi/work/git/ndsl/external/dace/dace/codegen/dispatcher.py", line 466, in dispatch_scope
    self._map_dispatchers[map_schedule].generate_scope(sdfg, cfg, sub_dfg, state_id, function_stream,
  File "/home/fgdeconi/work/git/ndsl/external/dace/dace/codegen/targets/cuda.py", line 1656, in generate_scope
    cudastream = '__state->gpu_context->streams[%d]' % scope_entry._cuda_stream
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MapEntry' object has no attribute '_cuda_stream'

There's a unit test testing this exact code. But the test doesn't call the program directly, instead it runs

    sdfg = multidimred.to_sdfg(a, b)
    sdfg.apply_gpu_transformations()

which, indeed fixes the present issue, but arguably shouldn't be needed.

PS: The cupy.max is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions