# device data on a different module

**URL:** <https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [March 6, 2012, 10:27pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815 "2012-03-06T22:27:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [March 6, 2012, 10:27pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/1 "2012-03-06T22:27:34Z")

</div>

Hi,  
May I ask the current status of using device data as well as kernels defined in one module and being used in another module in CUDA Fortran. Has it been fully supported or not.

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [March 6, 2012, 10:46pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/2 "2012-03-06T22:46:44Z")

</div>

Hi Tuan,

Yes, this has been supported since 11.6. Caveat is that this requires runtime support only available on a card with Compute Capability 2.0 (Fermi) or greater and CUDA 4.0 or later.

- Mat

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [March 7, 2012, 2:30pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/3 "2012-03-07T14:30:07Z")

</div>

Hi Mat,  
I defined a _attributes(device,host)_ subprogram from another module and I get the following error.

```nohighlight
PGF90-S-0155-Illegal call of a device routine from another module - state_breakdown (src/ecc_gpu_utility.f95: 998)
  0 inform, 0 warnings, 1 severes, 0 fatal for get_comppdt_2
PGF90-S-0155-Illegal call of a device routine from another module - state_breakdown (src/ecc_gpu_utility.f95: 1059)
  0 inform, 0 warnings, 1 severes, 0 fatal for get_comppdt_2b
PGF90-S-0155-Illegal call of a device routine from another module - state_breakdown (src/ecc_gpu_utility.f95: 1129)
PGF90-S-0155-Illegal call of a device function from another module - state_combine_single (src/ecc_gpu_utility.f95: 1257)
  0 inform, 0 warnings, 2 severes, 0 fatal for updatesystem_2
PGF90-S-0155-Illegal call of a device routine from another module - state_breakdown (src/ecc_gpu_utility.f95: 1367)
PGF90-S-0155-Illegal call of a device function from another module - state_combine_single (src/ecc_gpu_utility.f95: 1504)
  0 inform, 0 warnings, 2 severes, 0 fatal for updatesystem_2b

```

I remembered that the previous versions of PGI CUDA Fortran didn’t do well on code combining device and host subprogram, and suggested users to write 2 separately. How about the status in 12.2 version?

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [March 7, 2012, 4:01pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/4 "2012-03-07T16:01:48Z")

</div>

Hi Tuan,

While I don’t think our engineers have entirely given-up on “attributes(device,host)”, it turned out to be extremely difficult to implement so has not be done yet.

Note, that I should have prefaced my earlier post with that only global kernels can be called externally. Device routines are only callable from within the same module.

- Mat

---

<div class="post-metadata">

**Author:** ![Tuan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tuan](https://forums.developer.nvidia.com/u/Tuan)\
**Post date:** [March 11, 2012, 2:00am UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/5 "2012-03-11T02:00:06Z")

</div>

Hi Mat,  
I want to ask a question. Is there a trade-off when declaring device data on one module and use it in kernels from another module, compared to putting kernel and device data in the same module.

Thanks,  
Tuan

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [March 12, 2012, 4:00pm UTC](https://forums.developer.nvidia.com/t/device-data-on-a-different-module/132815/6 "2012-03-12T16:00:21Z")

</div>

Hi Tuan,

Performance-wise there’s not much of a difference. The external module data requires a runtime look-up call to get the address, but it’s impact is small.

- Mat
