Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

LOGICAL size choice

ereisch
Novice
203 Views

Is there an optimal size choice for local variables of LOGICAL data types for efficiency on x86 or x86_64 platforms?  I understand the desire to pad alignment of structures or arrays of structures for efficiency, but do non-array stack variables access any quicker for 1-byte vs. 4-byte accesses?  Same question for INTEGER*1 or INTEGER*2 vs. INTEGER*4 -- is there any reason to not compress the variable size to the smallest needed to store the expected data?

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
198 Views

The instructions for manipulating LOGICALs work better when the data is 32-bit aligned. Unless you have hundreds of thousands of these, the default size is the better choice.

View solution in original post

2 Replies
Steve_Lionel
Black Belt Retired Employee
199 Views

The instructions for manipulating LOGICALs work better when the data is 32-bit aligned. Unless you have hundreds of thousands of these, the default size is the better choice.

View solution in original post

jimdempseyatthecove
Black Belt
178 Views

I agree with Steve with one (rare exception). This is for the special case where your highly exercized procedure (subroutine or function) is on the edge of fitting everything in L1 cache .AND. where you have the opportunity to reclaim some cache lines by packing your logicals and smaller integers. I would suggest you not use the smaller sizes until after you reach the VTune phase and notice/determine a potential for gain.

For hundreds of thousands of logicals, you might consider bit fields. YMMV

Jim Dempsey

Reply