Skip to content

can't define a __device__ kernel function that returns void type #28

Open
@takagi

Description

@takagi

Currently, a function specifier is determined by its return type, that __global__ for void type and __device__ for not void type.

For example,

(defkernel foo (void ())
  (return))

is compiled into:

__global__ void foo () {
  return;
}

Because of this rule, a __device__ kernel function that returns void type can't be defined.

To solve this problem, following syntaxes may be given:

(defdevicekernel foo (void ()) ...
(defkernel (foo :device) (void ()) ...
(defkernel foo :device (void ()) ...
(defkernel foo ((void :device) ()) ...
(defkernel foo (void :device ()) ...

I think of choosing the second one. Function specifiers can be omitted and the current rule is applied in such case.

:global is specified:

(defkernel (foo :global) (void ())
  (return))
;; compiled into: __global__ void foo () { ... }

:device is specified:

(defkernel (bar :device) (void ())
  (return))
;; compiled into: __device__ void bar () { ... }

__global__ is complemented because return type is void:

(defkernel foofoo (void ())
  (return))
;; compiled into: __global__ void foofoo () { ... }

__device__ is complemented because return type is int:

(defkernel baz (int ())
  (return 1))
;; compiled into: __device__ int baz () { ... }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions