-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiP: resolved some minor errors that raised from the initial clone of the branch #45
base: feature/openacc-library-routines
Are you sure you want to change the base?
WiP: resolved some minor errors that raised from the initial clone of the branch #45
Conversation
HIP_CHECK(hipMemGetInfo(&free, &total)) | ||
return free; | ||
case gpufortrt_property_free_memory: | ||
size_t freeMem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the renaming? Usage of camelCase does not fit with rest of code base. I am planning to adopt the LLVM programming style eventually but not for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In switch case, the scope of variables is the switch not the cases: we get errors about the redefinition of variables free and total.
Either we have to put the definition of free and total in the switch (which looks weird) or we need to define new variables. How about free_mem and total_mem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in commit 59d4293
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more things:
- Probably makes sense in this case to declare the inout arguments outside
of the case to prevent naming conflicts. - Alternatively, you can use '{' and '}' like this
case <label> { ... }
( don't forget to break )
to have a local scope for variables within the different cases where needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took first option and fixed it in commit a69f450
@@ -629,6 +629,7 @@ def is_end_statement_(tokens, kind): | |||
current_linemap["statements"]): | |||
try: | |||
expand_statement_functions_(current_statement) | |||
original_statement = current_statement["body"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't accept frontend changes now as I am currently changing it on a separate development branch.
I suggest to keep a local copy and not include to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to reject the changes. I have local copies.
@@ -1942,6 +1942,10 @@ def is_declaration(tokens): | |||
def is_blank_line(statement): | |||
return not len(statement.strip()) | |||
|
|||
def is_acc_rtlib(statement, modern_fortran): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't accept frontend changes now as I am currently changing it on a separate development branch.
I suggest to keep a local copy and not include to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please feel free to reject the changes. I have local copies
! | ||
end function | ||
end interface | ||
if(c_associated(gpufortrt_is_present_c_impl(c_loc(data_arg),int(bytes,kind=c_size_t)))) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can make an assignment out of this.
Please further do not use the camelCase for the result arg,
breaks with the OpenACC look and feel.
You could also just write
logical :: gpufortrt_is_present
...
gpufort_is_present = c_associated(...)
and get rid of the result(...)
alltogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in commit 59d4293
@@ -292,4 +292,31 @@ function gpufortrt_use_device_c_impl(hostptr,condition,if_present) & | |||
resultptr = gpufortrt_use_device_c_impl(hostptr,opt_if_arg,opt_if_present_arg) | |||
end function | |||
|
|||
function gpufortrt_is_present(data_arg, bytes) result(isOnDeviceMemory) | |||
use iso_c_binding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not intended (in this case it shouldn't), try not to forget the implicit none
after the use
statements and before the first declaration / line of code.
Otherwise, Fortran's default implicit naming rules are active, which based on the first letter of an identifier
will assign a default integer or real type to undeclared variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in commit 59d4293
interface | ||
function gpufortrt_is_present_c_impl(data_arg, bytes) & | ||
bind(c,name="gpufortrt_present") result(isOnDeviceMemory) | ||
use iso_c_binding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use implicit none
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use implicit none once at the module scope? This way we don't need to repeat it for every interface/function/subroutine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in commit 59d4293
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do that (works both for program
and module
) but it would not apply to the interfaces; see
https://stackoverflow.com/a/24337734
Which can cause confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then, I avoid putting it at module scope to keep it clear
!> \param[in] if_present Only return device pointer if one could be found for the host pointer. | ||
!> otherwise host pointer is returned. Defaults to '.false.'. | ||
!> \note Returns a c_null_ptr if the host pointer is invalid, i.e. not C associated. | ||
subroutine gpufortrt_use_device(resultptr, hostptr,sizes,lbounds,if_arg,if_present) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on use_device, as it doesn't work at the moment:
I didnt get the logic in previous implementation.
Commits 4 & 5: Fixed the issues raised in comments
Commit 3: Updated python part
Commit 2: additional examples to test acc rtlib
Commit 1: resolved minor errors in forked repo