Skip to content

Conversation

@Jaypat12
Copy link

#89

Updated test replaces the incorrect usage of acc_malloc and acc_free from earlier versions.
The original test used an INTEGER POINTER and assumed acc_malloc could directly allocate into Fortran arrays, which is not valid. It also passed incompatible types to acc_free.

In the revised version, acc_malloc is properly used to return a C_PTR as specified by
the OpenACC API, and acc_free is correctly called with an argument of TYPE(C_PTR).
The test now uses ISO_C_BINDING to ensure type safety and portability, computing
allocation size using C_SIZEOF and ensuring the size is passed as a C_SIZE_T.

Additionally, the test checks pointer validity using C_ASSOCIATED and validates memory
restoration using precise comparisons between initial and final free memory values.

Copy link

@tob2 tob2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

final_memory = acc_get_property(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_free_memory)

IF (final_memory .lt. (initial_memory + size(a))) THEN
IF (initial_memory - final_memory > PRECISION) THEN
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For integers, I would simply use:

Suggested change
IF (initial_memory - final_memory > PRECISION) THEN
IF (initial_memory /= final_memory) THEN


DO x = 1, LOOPCOUNT
IF (final_memory + N * sizeof(a(1)) .gt. initial_memory) THEN
IF (initial_memory - final_memory > PRECISION) THEN
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise; those are integers:

Suggested change
IF (initial_memory - final_memory > PRECISION) THEN
IF (initial_memory /= final_memory) THEN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants