!===============================================================================
!
! module_simd.F90
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2012-2015 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/>.
!
!-------------------------------------------------------------------------------
# define LANGUAGE_FORTRAN
# include "simd.h"

!-------------------------------------------------------------------------------
module module_simd

  use typedef_simd


FOR rkind in 4 8
SET _rr = _r %% rkind
  type(simd_real%%_rr), external :: simd_zero%%_rr
  type(simd_real%%_rr), external :: simd_loads%%_rr
  type(simd_real%%_rr), external :: simd_load%%_rr
  type(simd_real%%_rr), external :: simd_loadu%%_rr
  type(simd_real%%_rr), external :: simd_shiftleft2%%_rr
  type(simd_real%%_rr), external :: simd_sum%%_rr
  type(simd_real%%_rr), external :: simd_diff%%_rr
  type(simd_real%%_rr), external :: simd_prod%%_rr
  type(simd_real%%_rr), external :: simd_fmadd%%_rr
  type(simd_real%%_rr), external :: simd_fmsub%%_rr
  real(rkind), external :: simd_reduction_sum%%_rr
ENDSET
ENDFOR

  interface assignment(=)
     module procedure copy_simd_r4
     module procedure copy_simd_r8
  end interface

contains

FOR _rr in _r4 _r8
  subroutine copy_simd%%_rr(out, in)
    type(simd_real%%_rr), intent(out) :: out
    type(simd_real%%_rr), intent(in) :: in
    out%r(:) = in%r(:)
  end subroutine copy_simd%%_rr
ENDFOR

end

!===============================================================================
