Skip to content

Commit

Permalink
Merge branch 'users/phschaad/adapt_passes' into users/phschaad/cf_blo…
Browse files Browse the repository at this point in the history
…ck_data_deps
  • Loading branch information
phschaad committed Nov 25, 2024
2 parents 682f960 + c61af96 commit 1ea1d37
Show file tree
Hide file tree
Showing 16 changed files with 662 additions and 275 deletions.
3 changes: 3 additions & 0 deletions dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3940,6 +3940,9 @@ def _parse_sdfg_call(self, funcname: str, func: Union[SDFG, SDFGConvertible], no
for arg in args_to_remove:
args.remove(arg)

# Refresh temporary transient counter of the nested SDFG
sdfg.refresh_temp_transients()

# Change connector names
updated_args = []
arrays_before = list(sdfg.arrays.items())
Expand Down
2 changes: 1 addition & 1 deletion dace/runtime/include/dace/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ namespace dace
{
namespace math
{
static DACE_CONSTEXPR typeless_pi pi{};
static DACE_CONSTEXPR DACE_HostDev typeless_pi pi{};
static DACE_CONSTEXPR typeless_nan nan{};
//////////////////////////////////////////////////////
template<typename T>
Expand Down
100 changes: 59 additions & 41 deletions dace/runtime/include/dace/nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,101 +13,119 @@ namespace dace
// Defines a typeless Pi
struct typeless_nan
{
DACE_CONSTEXPR DACE_HDFI typeless_nan() noexcept = default;
DACE_CONSTEXPR DACE_HDFI typeless_nan(const typeless_nan&) noexcept = default;
DACE_CONSTEXPR DACE_HDFI typeless_nan(typeless_nan&&) noexcept = default;
DACE_HDFI ~typeless_nan() noexcept = default;

#ifndef DACE_XILINX
DACE_CONSTEXPR DACE_HDFI typeless_nan& operator=(const typeless_nan&) noexcept = default;
DACE_CONSTEXPR DACE_HDFI typeless_nan& operator=(typeless_nan&&) noexcept = default;
#endif

operator int() const = delete;
operator float() const
DACE_CONSTEXPR DACE_HDFI operator float() const
{
return std::numeric_limits<float>::quiet_NaN();
}
operator double() const
DACE_CONSTEXPR DACE_HDFI operator double() const
{
return std::numeric_limits<double>::quiet_NaN();
}
operator long double() const

#if !( defined(__CUDACC__) || defined(__HIPCC__) )
//There is no long double on the GPU
DACE_CONSTEXPR DACE_HDFI operator long double() const
{
return std::numeric_limits<long double>::quiet_NaN();
}
typeless_nan operator+() const
#endif
DACE_CONSTEXPR DACE_HDFI typeless_nan operator+() const
{
return typeless_nan{};
}
typeless_nan operator-() const
DACE_CONSTEXPR DACE_HDFI typeless_nan operator-() const
{
return typeless_nan{};
}
};

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator*(const T&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator*(const T&, const typeless_nan&) noexcept { return typeless_nan{}; }

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator*(const typeless_nan&, const T&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator*(const typeless_nan&, const T&) noexcept { return typeless_nan{}; }

inline typeless_nan
operator*(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI typeless_nan
operator*(const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }


template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator+(const T&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator+(const T&, const typeless_nan&) noexcept { return typeless_nan{}; }

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator+(const typeless_nan&, const T&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator+(const typeless_nan&, const T&) noexcept { return typeless_nan{}; }

inline typeless_nan
operator+(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI typeless_nan
operator+(const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }


template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator-(const T&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator-(const T&, const typeless_nan&) noexcept { return typeless_nan{}; }

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator-(const typeless_nan&, const T&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator-(const typeless_nan&, const T&) noexcept { return typeless_nan{}; }

inline typeless_nan
operator-(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI typeless_nan
operator-(const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }


template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator/(const T&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator/(const T&, const typeless_nan&) noexcept { return typeless_nan{}; }

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator/(const typeless_nan&, const T&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator/(const typeless_nan&, const T&) noexcept { return typeless_nan{}; }

inline typeless_nan
operator/(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI typeless_nan
operator/(const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }


template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator%(const T&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator%(const T&, const typeless_nan&) noexcept { return typeless_nan{}; }

template<typename T>
DACE_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, typeless_nan>::type
operator%(const typeless_nan&, const T&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI std::enable_if_t<std::is_floating_point<T>::value || std::is_integral<T>::value, typeless_nan>
operator%(const typeless_nan&, const T&) noexcept { return typeless_nan{}; }

inline typeless_nan
operator%(const typeless_nan&, const typeless_nan&) { return typeless_nan{}; }
DACE_CONSTEXPR DACE_HDFI typeless_nan
operator%(const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }

}
}
DACE_HDFI typeless_nan ipow(const typeless_nan&, const unsigned int&) {
return typeless_nan{};
}

//These functions allows to perfrom operations with `typeless_nan` instances.
# define FADAPT(F) DACE_CONSTEXPR ::dace::math::typeless_nan F (::dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; }
# define FADAPT2(F) template<typename T1> DACE_CONSTEXPR dace::math::typeless_nan F (T1&&, dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; }; \
template<typename T2> DACE_CONSTEXPR dace::math::typeless_nan F (dace::math::typeless_nan, T2&&) { return ::dace::math::typeless_nan{}; }; \
DACE_CONSTEXPR ::dace::math::typeless_nan F (dace::math::typeless_nan, dace::math::typeless_nan) { return ::dace::math::typeless_nan{}; }
# define FADAPT(F) DACE_CONSTEXPR DACE_HDFI typeless_nan F (const typeless_nan&) noexcept { return typeless_nan{}; }
# define FADAPT2(F) template<typename T1> DACE_CONSTEXPR DACE_HDFI typeless_nan F (T1&&, dace::math::typeless_nan) noexcept { return typeless_nan{}; }; \
template<typename T2> DACE_CONSTEXPR DACE_HDFI typeless_nan F (const typeless_nan&, T2&&) noexcept { return typeless_nan{}; }; \
DACE_CONSTEXPR DACE_HDFI typeless_nan F (const typeless_nan&, const typeless_nan&) noexcept { return typeless_nan{}; }
FADAPT(tanh); FADAPT(cos); FADAPT(sin); FADAPT(sqrt); FADAPT(tan);
FADAPT(acos); FADAPT(asin); FADAPT(atan); FADAPT(log); FADAPT(exp);
FADAPT(floor); FADAPT(ceil); FADAPT(round); FADAPT(abs);
FADAPT2(max); FADAPT2(min);
# undef FADAPT2
# undef FADAPT
}
}


#endif // __DACE_NAN_H
Loading

0 comments on commit 1ea1d37

Please sign in to comment.