From ca5e3b8026dc49e328cdf9ae37054aaf0a2058ac Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Wed, 17 Jul 2024 11:04:02 +0200 Subject: [PATCH] Redefine complex algebraic functions as C macros --- build/Makefile.am | 2 +- build/Makefile.in | 11 ++--------- src/include/sph_subs.h | 2 +- src/include/types.h | 16 +++------------- src/libnptm/sph_subs.cpp | 2 ++ src/libnptm/types.cpp | 39 --------------------------------------- 6 files changed, 9 insertions(+), 63 deletions(-) delete mode 100644 src/libnptm/types.cpp diff --git a/build/Makefile.am b/build/Makefile.am index eb8b8935..0456b5e5 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -1,6 +1,6 @@ LDADD=libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLDFLAGS} ${MAGMALDFLAGS} lib_LTLIBRARIES=libnptm/libnptm.la -libnptm_libnptm_la_SOURCES=../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp ../src/libnptm/types.cpp +libnptm_libnptm_la_SOURCES=../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp bin_PROGRAMS=cluster/edfb_clu cluster/clu cluster/np_cluster sphere/edfb_sph sphere/sph sphere/np_sphere trapping/frfme trapping/lffft trapping/np_trapping testing/test_TEDF testing/test_TTMS cluster_edfb_clu_SOURCES=../src/cluster/edfb_clu.f cluster_clu_SOURCES=../src/cluster/clu.f diff --git a/build/Makefile.in b/build/Makefile.in index 98ff73a9..971793bf 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -145,8 +145,7 @@ am_libnptm_libnptm_la_OBJECTS = ../src/libnptm/algebraic.lo \ ../src/libnptm/lapack_calls.lo ../src/libnptm/logging.lo \ ../src/libnptm/magma_calls.lo ../src/libnptm/Parsers.lo \ ../src/libnptm/sph_subs.lo ../src/libnptm/tfrfme.lo \ - ../src/libnptm/TransitionMatrix.lo ../src/libnptm/tra_subs.lo \ - ../src/libnptm/types.lo + ../src/libnptm/TransitionMatrix.lo ../src/libnptm/tra_subs.lo libnptm_libnptm_la_OBJECTS = $(am_libnptm_libnptm_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -254,7 +253,6 @@ am__depfiles_remade = ../src/cluster/$(DEPDIR)/cluster.Po \ ../src/libnptm/$(DEPDIR)/sph_subs.Plo \ ../src/libnptm/$(DEPDIR)/tfrfme.Plo \ ../src/libnptm/$(DEPDIR)/tra_subs.Plo \ - ../src/libnptm/$(DEPDIR)/types.Plo \ ../src/sphere/$(DEPDIR)/np_sphere.Po \ ../src/sphere/$(DEPDIR)/sphere.Po \ ../src/testing/$(DEPDIR)/test_TEDF.Po \ @@ -522,7 +520,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ LDADD = libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLDFLAGS} ${MAGMALDFLAGS} lib_LTLIBRARIES = libnptm/libnptm.la -libnptm_libnptm_la_SOURCES = ../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp ../src/libnptm/types.cpp +libnptm_libnptm_la_SOURCES = ../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp cluster_edfb_clu_SOURCES = ../src/cluster/edfb_clu.f cluster_clu_SOURCES = ../src/cluster/clu.f cluster_np_cluster_SOURCES = ../src/cluster/np_cluster.cpp ../src/cluster/cluster.cpp @@ -687,8 +685,6 @@ clean-libLTLIBRARIES: ../src/libnptm/$(DEPDIR)/$(am__dirstamp) ../src/libnptm/tra_subs.lo: ../src/libnptm/$(am__dirstamp) \ ../src/libnptm/$(DEPDIR)/$(am__dirstamp) -../src/libnptm/types.lo: ../src/libnptm/$(am__dirstamp) \ - ../src/libnptm/$(DEPDIR)/$(am__dirstamp) libnptm/$(am__dirstamp): @$(MKDIR_P) libnptm @: > libnptm/$(am__dirstamp) @@ -834,7 +830,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@../src/libnptm/$(DEPDIR)/sph_subs.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@../src/libnptm/$(DEPDIR)/tfrfme.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@../src/libnptm/$(DEPDIR)/tra_subs.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@../src/libnptm/$(DEPDIR)/types.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@../src/sphere/$(DEPDIR)/np_sphere.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@../src/sphere/$(DEPDIR)/sphere.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@../src/testing/$(DEPDIR)/test_TEDF.Po@am__quote@ # am--include-marker @@ -1203,7 +1198,6 @@ distclean: distclean-am -rm -f ../src/libnptm/$(DEPDIR)/sph_subs.Plo -rm -f ../src/libnptm/$(DEPDIR)/tfrfme.Plo -rm -f ../src/libnptm/$(DEPDIR)/tra_subs.Plo - -rm -f ../src/libnptm/$(DEPDIR)/types.Plo -rm -f ../src/sphere/$(DEPDIR)/np_sphere.Po -rm -f ../src/sphere/$(DEPDIR)/sphere.Po -rm -f ../src/testing/$(DEPDIR)/test_TEDF.Po @@ -1273,7 +1267,6 @@ maintainer-clean: maintainer-clean-am -rm -f ../src/libnptm/$(DEPDIR)/sph_subs.Plo -rm -f ../src/libnptm/$(DEPDIR)/tfrfme.Plo -rm -f ../src/libnptm/$(DEPDIR)/tra_subs.Plo - -rm -f ../src/libnptm/$(DEPDIR)/types.Plo -rm -f ../src/sphere/$(DEPDIR)/np_sphere.Po -rm -f ../src/sphere/$(DEPDIR)/sphere.Po -rm -f ../src/testing/$(DEPDIR)/test_TEDF.Po diff --git a/src/include/sph_subs.h b/src/include/sph_subs.h index aafd6f5e..66a3f630 100644 --- a/src/include/sph_subs.h +++ b/src/include/sph_subs.h @@ -75,7 +75,7 @@ double cg1(int lmpml, int mu, int l, int m); * \param z: `complex double` The input complex number. * \return result: `complex double` The conjugate of the input number. */ -dcomplex dconjg(dcomplex z); +// dcomplex dconjg(dcomplex z); /*! \brief Comute the continuous variation of the refractive index and of its radial derivative. * diff --git a/src/include/types.h b/src/include/types.h index 93a1bfea..742a5ff8 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -62,17 +62,7 @@ typedef __complex__ double dcomplex; #endif // lapack_int #endif // np_int -/*! \brief Get the real part of a complex number. - * - * \param z: `complex double` The argument of the function. - * \return rz: `double` The real part of the argument. - */ -double real(dcomplex z); - -/*! \brief Get the imaginary part of a complex number. - * - * \param z: `complex double` The argument of the function. - * \return iz: `double` The imaginary part of the argument. - */ -double imag(dcomplex z); +#define imag(z) ( __imag__ (z) ) +#define real(z) ( __real__ (z) ) +#define dconjg(z) ( (__real__ (z) - I * (__imag__ (z))) ) #endif diff --git a/src/libnptm/sph_subs.cpp b/src/libnptm/sph_subs.cpp index 63685f97..1b5a8e6a 100644 --- a/src/libnptm/sph_subs.cpp +++ b/src/libnptm/sph_subs.cpp @@ -197,6 +197,7 @@ double cg1(int lmpml, int mu, int l, int m) { return result; } +/* #ifdef USE_TARGET_OFFLOAD #pragma omp begin declare target device_type(any) #endif @@ -208,6 +209,7 @@ dcomplex dconjg(dcomplex z) { #ifdef USE_TARGET_OFFLOAD #pragma omp end declare target #endif +*/ void diel(int npntmo, int ns, int i, int ic, double vk, C1 *c1, C2 *c2) { const double dif = c1->rc[i - 1][ns] - c1->rc[i - 1][ns - 1]; diff --git a/src/libnptm/types.cpp b/src/libnptm/types.cpp deleted file mode 100644 index 4b2bd233..00000000 --- a/src/libnptm/types.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2024 INAF - Osservatorio Astronomico di Cagliari - - This program 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. - - This program 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. - - A copy of the GNU General Public License is distributed along with - this program in the COPYING file. If not, see: <https://www.gnu.org/licenses/>. - */ - -/*! \file types.cpp - * - * \brief Implementation of the functions connected with types. - */ -#ifndef INCLUDE_TYPES_H_ -#include "../include/types.h" -#endif - -#ifdef USE_TARGET_OFFLOAD -# pragma omp begin declare target device_type(any) -#endif -double real(dcomplex z) { return __real__ z; } -#ifdef USE_TARGET_OFFLOAD -# pragma omp end declare target -#endif - -#ifdef USE_TARGET_OFFLOAD -# pragma omp begin declare target device_type(any) -#endif -double imag(dcomplex z) { return __imag__ z; } -#ifdef USE_TARGET_OFFLOAD -# pragma omp end declare target -#endif -- GitLab