- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need use flag variables for intensive use in user defined types, but I'm not sure about the faster way for this. I'm considering two possibilities. The first one is use directly logical variables, as follow:
type node_t
....
logical(1), dimension(4) :: flag
...
end type
integer, parameter :: ACTIVE = 1
and the use is:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( node%flag(ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
The second possibility is use bit intrinsic function, with integer variables:
type node_t
....
integer(1) :: flag
...
end type
integer(1), parameter :: ACTIVE
with:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( btest(node%flag,ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
Someone can say something about the better way for this,
in order to obtain a good performance, I will really appreciated.
thanks
I need use flag variables for intensive use in user defined types, but I'm not sure about the faster way for this. I'm considering two possibilities. The first one is use directly logical variables, as follow:
type node_t
....
logical(1), dimension(4) :: flag
...
end type
integer, parameter :: ACTIVE = 1
and the use is:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( node%flag(ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
The second possibility is use bit intrinsic function, with integer variables:
type node_t
....
integer(1) :: flag
...
end type
integer(1), parameter :: ACTIVE
with:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( btest(node%flag,ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
Someone can say something about the better way for this,
in order to obtain a good performance, I will really appreciated.
thanks
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would really have to test performance yourself. If you do a significant amount of other processing, and the code isn't vectorizable, it seems unlikely you could measure a performance difference between your proposals. For potentially vectorizable code, you might have to evaluate default logical data types, if you are willing to use more data space to gain speed.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page