﻿# hipModuleLaunchKernel: an argument pointer array is not a packed argument buffer

Construct HIP module launch arguments using a declared representation, preserving scalar widths, pointer values, layout and alignment rather than conflating kernelParams and extra.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-hip-module-launch-argument-abi-packing/
Language: en

## Choose the argument representation explicitly

A launcher changes from normal HIP kernel syntax to hipModuleLaunchKernel and reuses an array prepared for another interface. The [execution API reference](https://rocm.docs.amd.com/projects/HIP/en/latest/reference/hip_runtime_api/modules/execution_control.html) distinguishes kernel parameters and the extra argument path. An array pointing to host-side argument values is a different structure from a packed buffer containing the argument bytes themselves. Decide which representation is being built before checking whether the launch dimensions look reasonable.

## Keep pointer values separate from their storage

For a kernel pointer parameter, the value passed to device code is the device address. The host variable holding that address also has its own host address. Confusing those levels can produce a launch with a valid-looking pointer-shaped value that refers to the wrong memory. Write down each parameter's declared type and intended value, then map it to the selected launch representation. Avoid generic pointer casts that erase whether a particular entry holds a value or points to its storage.

## Respect alignment instead of concatenating blindly

The [HIP porting guide](https://github.com/ROCm/HIP/blob/develop/docs/how-to/hip_porting_guide.rst) discusses module launch configuration and argument buffers. The extra path must agree with the compiled layout and alignment contract. Consecutively copying scalar bytes without padding can differ from the required layout. Mixed pointer, narrow integer and wider scalar arguments expose such errors more effectively than a demonstration containing only identical pointers. Preserve explicit widths and verify the installed interface rather than assuming a host structure always matches every device artifact.

## Inspect implementation evidence carefully

The [HIP runtime implementation](https://github.com/ROCm/clr/blob/develop/hipamd/src/hip_platform.cpp) shows argument-buffer configuration in the actual launch path. It is useful primary evidence for understanding representation, but an internal implementation detail is not a substitute for the public API contract. Check returned errors and completed output. A successful enqueue can coexist with incorrectly interpreted parameter bytes, so do not diagnose every incorrect result as an arithmetic kernel bug before validating the launch boundary.

## Compare a deliberately asymmetric fixture

Use a small kernel with distinct input values and differently sized parameters, and compare the module path with an ordinary checked launch. Ensure the buffers remain alive for asynchronous device use and the module belongs to the intended artifact. Guides on [HIP launch portability](/journal/learn-hip-launch-portability/) and [software reproducibility](/journal/software-stack-reproducibility/) provide context. This guide validates argument ABI transmission; it does not establish that two source-identical kernels have identical performance or resource usage.
