PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Device attribute mismatch

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
camaptrang



Joined: 28 May 2013
Posts: 19

PostPosted: Mon Jun 10, 2013 1:51 am    Post subject: Device attribute mismatch Reply with quote

Hi all,
I tried with a simple code to compute parallel. My code is
module simple
contains
attributes(global) subroutine increment(a,b)
implicit none
integer, intent(inout)::a(:)
integer,intent(in)::b
integer::i
i=threadIdx%x
a(i)=a(i)+b
return
end subroutine increment
end module simple
program incrementtest
use cudafor
use simple
implicit none
integer,parameter::n=256
integer::a(n),b
integer,device::a_d(n)
a=1
b=3
a_d=a
call increment<<<1,n>>>(a_d,b)
a=a_d
if (any(a.ne.4)) then
write(*,*) 'program failed'
else
write(*,*) 'program passed'
endif
end program incrementtest

I got an error
PGF90-S-0528-Argument number 2 to increment: device attribute mistach, line28.. I got the same error for another program.
Thank for avance
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Mon Jun 10, 2013 8:43 am    Post subject: Reply with quote

Hi camaptrang,

Since Fortran passes variables by reference, you're trying to pass b's host side address to the kernel. Instead, you need to pass "b" by value (i.e. the value of the variable is passed to the device not it's host address), by simply added the "value" attribute to "b" declaration.

Code:
attributes(global) subroutine increment(a,b)
implicit none
integer, intent(inout)::a(:)
integer,value, intent(in)::b
integer::i
i=threadIdx%x
a(i)=a(i)+b
return
end subroutine increment


Hope this helps,
Mat
Back to top
View user's profile
camaptrang



Joined: 28 May 2013
Posts: 19

PostPosted: Mon Jun 10, 2013 11:55 pm    Post subject: Device attribute mismatch Reply with quote

thank you very much mkcolg,
It work now
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group