#/*
#==============================================================================
#
# alignment.h
#
#------------------------------------------------------------------------------
#
# Copyright (C) 2015-2016 Hinnerk Stueben
#
# This file is part of BQCD -- Berlin Quantum ChromoDynamics program
#
# BQCD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BQCD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
#
#------------------------------------------------------------------------------
#*/

#ifdef ALIGNMENT_VALUE
# define ATTRIBUTE_ALIGNED __attribute__((aligned(ALIGNMENT_VALUE)))

#ifdef IBM
# define ATTRIBUTE_ALIGN(x)        !ibm* align(ALIGNMENT_VALUE, x)
# define ATTRIBUTE_ALIGN2(x, y)    !ibm* align(ALIGNMENT_VALUE, x, y)
# define ATTRIBUTE_ALIGN3(x, y, z) !ibm* align(ALIGNMENT_VALUE, x, y, z)
# define ASSUME_ALIGNED(x)         call alignx(ALIGNMENT_VALUE, x)

# define assume_alignment4(a,b,c,d) \
call alignx(ALIGNMENT_VALUE,a); \
call alignx(ALIGNMENT_VALUE,b); \
call alignx(ALIGNMENT_VALUE,c); \
call alignx(ALIGNMENT_VALUE,d)
# define assume_alignment5(a,b,c,d,e) \
call alignx(ALIGNMENT_VALUE,a); \
call alignx(ALIGNMENT_VALUE,b); \
call alignx(ALIGNMENT_VALUE,c); \
call alignx(ALIGNMENT_VALUE,d); \
call alignx(ALIGNMENT_VALUE,e) 
#endif

#ifdef INTEL
# define ATTRIBUTE_ALIGN(x)        !dir$ attributes align:ALIGNMENT_VALUE :: x
# define ATTRIBUTE_ALIGN2(x, y)    !dir$ attributes align:ALIGNMENT_VALUE :: x, y
# define ATTRIBUTE_ALIGN3(x, y, z) !dir$ attributes align:ALIGNMENT_VALUE :: x, y, z
# define ASSUME_ALIGNED(x)         !dir$ assume_aligned x:ALIGNMENT_VALUE 

# define assume_alignment4(a,b,c,d) !dir$ assume_aligned a:ALIGNMENT_VALUE, b:ALIGNMENT_VALUE, c:ALIGNMENT_VALUE, d:ALIGNMENT_VALUE
# define assume_alignment5(a,b,c,d,e) !dir$ assume_aligned a:ALIGNMENT_VALUE, b:ALIGNMENT_VALUE, c:ALIGNMENT_VALUE, d:ALIGNMENT_VALUE, e:ALIGNMENT_VALUE
#endif

#endif

#if ! defined (ALIGNMENT_VALUE) || defined (CRAY) || defined (GNU)
# define ATTRIBUTE_ALIGN(x)
# define ATTRIBUTE_ALIGN2(x, y)
# define ATTRIBUTE_ALIGN3(x, y, z)
# define ASSUME_ALIGNED(x)
# define assume_alignment4(a,b,c,d)
# define assume_alignment5(a,b,c,d,e)
#endif

#ifndef ALIGNMENT_ATTRIBUTES
# define ALIGNMENT_ATTRIBUTES
#endif
