@@ -130,12 +130,12 @@ class DualStorage<T, 1>
130130 // To better enable Scalar Replacement of Aggregates and other
131131 // transformations, CLANG has easier time if the per element
132132 // constructors declared.
133- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage () {}
134- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const T & val, const T & dx)
133+ OSL_HOSTDEVICE constexpr DualStorage () {}
134+ OSL_HOSTDEVICE constexpr DualStorage (const T & val, const T & dx)
135135 : m_val(val)
136136 , m_dx(dx)
137137 {}
138- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const DualStorage &other)
138+ OSL_HOSTDEVICE constexpr DualStorage (const DualStorage &other)
139139 : m_val(other.m_val)
140140 , m_dx(other.m_dx)
141141 {}
@@ -159,13 +159,13 @@ class DualStorage<T, 2>
159159 // To better enable Scalar Replacement of Aggregates and other
160160 // transformations, CLANG has easier time if the per element
161161 // constructors declared.
162- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage () {}
163- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const T & val, const T & dx, const T & dy)
162+ OSL_HOSTDEVICE constexpr DualStorage () {}
163+ OSL_HOSTDEVICE constexpr DualStorage (const T & val, const T & dx, const T & dy)
164164 : m_val(val)
165165 , m_dx(dx)
166166 , m_dy(dy)
167167 {}
168- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const DualStorage &other)
168+ OSL_HOSTDEVICE constexpr DualStorage (const DualStorage &other)
169169 : m_val(other.m_val)
170170 , m_dx(other.m_dx)
171171 , m_dy(other.m_dy)
@@ -192,15 +192,15 @@ class DualStorage<T, 3>
192192 // To better enable Scalar Replacement of Aggregates and other
193193 // transformations, CLANG has easier time if the per element
194194 // constructors declared.
195- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage () {}
196- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const T & val, const T & dx, const T & dy, const T & dz)
195+ OSL_HOSTDEVICE constexpr DualStorage () {}
196+ OSL_HOSTDEVICE constexpr DualStorage (const T & val, const T & dx, const T & dy, const T & dz)
197197 : m_val(val)
198198 , m_dx(dx)
199199 , m_dy(dy)
200200 , m_dz(dz)
201201 {}
202202
203- OSL_HOSTDEVICE OSL_CONSTEXPR14 DualStorage (const DualStorage &other)
203+ OSL_HOSTDEVICE constexpr DualStorage (const DualStorage &other)
204204 : m_val(other.m_val)
205205 , m_dx(other.m_dx)
206206 , m_dy(other.m_dy)
@@ -230,7 +230,7 @@ class Dual : public DualStorage<T, PARTIALS> {
230230 static_assert (PARTIALS>=1 , " Can't have a Dual with 0 partials" );
231231public:
232232 using value_type = T;
233- static OSL_FORCEINLINE OSL_HOSTDEVICE OSL_CONSTEXPR14 T zero () { return T (0.0 ); }
233+ static OSL_FORCEINLINE OSL_HOSTDEVICE constexpr T zero () { return T (0.0 ); }
234234
235235 using DualStorage<T, PARTIALS>::elem;
236236 template <int N>
@@ -240,13 +240,13 @@ class Dual : public DualStorage<T, PARTIALS> {
240240
241241 // / Default ctr leaves everything uninitialized
242242 // /
243- OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual ()
243+ OSL_HOSTDEVICE constexpr Dual ()
244244 : DualStorage<T, PARTIALS>()
245245 {}
246246
247247 // / Construct a Dual from just a real value (derivs set to 0)
248248 // /
249- OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const T &x)
249+ OSL_HOSTDEVICE constexpr Dual (const T &x)
250250 : DualStorage<T, PARTIALS>()
251251 {
252252 val () = x;
@@ -258,16 +258,16 @@ class Dual : public DualStorage<T, PARTIALS> {
258258 // / Copy constructor from another Dual of same dimension and different,
259259 // / but castable, data type.
260260 template <class F >
261- OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual<F,PARTIALS> &x)
261+ OSL_HOSTDEVICE constexpr Dual (const Dual<F,PARTIALS> &x)
262262 : DualStorage<T, PARTIALS>()
263263 {
264264 OSL_INDEX_LOOP (i, elements, {
265265 elem (i) = T (x.elem (i));
266266 });
267267 }
268268
269- // OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual &x) = default;
270- OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (const Dual &x)
269+ // OSL_HOSTDEVICE constexpr Dual (const Dual &x) = default;
270+ OSL_HOSTDEVICE constexpr Dual (const Dual &x)
271271 : DualStorage<T, PARTIALS>(x)
272272 {}
273273
@@ -297,7 +297,7 @@ class Dual : public DualStorage<T, PARTIALS> {
297297 set_expander (pvt::make_int_sequence<elements>(), values...);
298298 }
299299
300- OSL_HOSTDEVICE OSL_CONSTEXPR14 Dual (std::initializer_list<T> vals) {
300+ OSL_HOSTDEVICE constexpr Dual (std::initializer_list<T> vals) {
301301#if OIIO_CPLUSPLUS_VERSION >= 14
302302 static_assert (vals.size () == elements, " Wrong number of initializers" );
303303#endif
@@ -401,7 +401,7 @@ template<class T> using Dual2 = Dual<T,2>;
401401// / Addition of duals.
402402// /
403403template <class T , int P>
404- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator + (const Dual<T,P> &a, const Dual<T,P> &b)
404+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator + (const Dual<T,P> &a, const Dual<T,P> &b)
405405{
406406 Dual<T,P> result = a;
407407 OSL_INDEX_LOOP (i, P+1 , {
@@ -412,7 +412,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T
412412
413413
414414template <class T , int P>
415- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator + (const Dual<T,P> &a, const T &b)
415+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator + (const Dual<T,P> &a, const T &b)
416416{
417417 Dual<T,P> result = a;
418418 result.val () += b;
@@ -421,7 +421,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator+ (const Dual<T
421421
422422
423423template <class T , int P>
424- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator + (const T &a, const Dual<T,P> &b)
424+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator + (const T &a, const Dual<T,P> &b)
425425{
426426 Dual<T,P> result = b;
427427 result.val () += a;
@@ -450,7 +450,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P>& operator+= (Dual<T,P> &a, const T &b)
450450// / Subtraction of duals.
451451// /
452452template <class T , int P>
453- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator - (const Dual<T,P> &a, const Dual<T,P> &b)
453+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator - (const Dual<T,P> &a, const Dual<T,P> &b)
454454{
455455 Dual<T,P> result;
456456 OSL_INDEX_LOOP (i, P+1 , {
@@ -461,7 +461,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
461461
462462
463463template <class T , int P>
464- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator - (const Dual<T,P> &a, const T &b)
464+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator - (const Dual<T,P> &a, const T &b)
465465{
466466 Dual<T,P> result = a;
467467 result.val () -= b;
@@ -470,7 +470,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
470470
471471
472472template <class T , int P>
473- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator - (const T &a, const Dual<T,P> &b)
473+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator - (const T &a, const Dual<T,P> &b)
474474{
475475 Dual<T,P> result;
476476 result.val () = a - b.val ();
@@ -503,7 +503,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P>& operator-= (Dual<T,P> &a, const T &b)
503503// / Negation of duals.
504504// /
505505template <class T , int P>
506- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator - (const Dual<T,P> &a)
506+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator - (const Dual<T,P> &a)
507507{
508508 Dual<T,P> result;
509509 OSL_INDEX_LOOP (i, P+1 , {
@@ -516,7 +516,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator- (const Dual<T
516516// / Multiplication of duals. This will work for any Dual<T>*Dual<S>
517517// / where T*S is meaningful.
518518template <class T , int P, class S >
519- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
519+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
520520operator * (const Dual<T,P> &a, const Dual<S,P> &b) -> Dual<decltype (a.val()*b.val()),P>
521521{
522522 // Use the chain rule
@@ -533,7 +533,7 @@ operator* (const Dual<T,P> &a, const Dual<S,P> &b) -> Dual<decltype(a.val()*b.va
533533// / Dual<T> * S where T*S is meaningful.
534534template <class T , int P, class S ,
535535 DUAL_REQUIRES (is_Dual<S>::value == false )>
536- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
536+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
537537operator* (const Dual<T,P> &a, const S &b) -> Dual<decltype(a.val()*b),P>
538538{
539539 Dual<decltype (a.val ()*b),P> result;
@@ -562,7 +562,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE const Dual<T,P>& operator*= (Dual<T,P> &a, const
562562// / Dual<T> * S where T*S is meaningful.
563563template <class T , int P, class S ,
564564 DUAL_REQUIRES (is_Dual<S>::value == false )>
565- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 auto
565+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr auto
566566operator* (const S &b, const Dual<T,P> &a) -> Dual<decltype(a.val()*b),P>
567567{
568568 return a*b;
@@ -573,7 +573,7 @@ operator* (const S &b, const Dual<T,P> &a) -> Dual<decltype(a.val()*b),P>
573573// / Division of duals.
574574// /
575575template <class T , int P>
576- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator / (const Dual<T,P> &a, const Dual<T,P> &b)
576+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator / (const Dual<T,P> &a, const Dual<T,P> &b)
577577{
578578 T bvalinv = T (1 ) / b.val ();
579579 T aval_bval = a.val () / b.val ();
@@ -589,7 +589,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T
589589// / Division of dual by scalar.
590590// /
591591template <class T , int P>
592- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator / (const Dual<T,P> &a, const T &b)
592+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator / (const Dual<T,P> &a, const T &b)
593593{
594594 T bvalinv = T (1 ) / b;
595595 T aval_bval = a.val () / b;
@@ -605,7 +605,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator/ (const Dual<T
605605// / Division of scalar by dual.
606606// /
607607template <class T , int P>
608- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> operator / (const T &aval, const Dual<T,P> &b)
608+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> operator / (const T &aval, const Dual<T,P> &b)
609609{
610610 T bvalinv = T (1 ) / b.val ();
611611 T aval_bval = aval / b.val ();
@@ -742,12 +742,12 @@ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalVal (const T &x, const Dual<T
742742// / equalAll is the same as equalVal generally, but for two Duals of the same
743743// / type, they also compare derivs.
744744template <class T >
745- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const T &x, const T &y) {
745+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalAll (const T &x, const T &y) {
746746 return equalVal (x, y);
747747}
748748
749749template <class T , int P>
750- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const Dual<T,P> &x, const Dual<T,P> &y) {
750+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr bool equalAll (const Dual<T,P> &x, const Dual<T,P> &y) {
751751 bool r = true ;
752752 OSL_INDEX_LOOP (i, P+1 , {
753753 r &= (x.elem (i) == y.elem (i));
@@ -763,7 +763,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 bool equalAll (const Dual<T,P> &x
763763// function f(scalar), then the dual function F(<u,u'>) is defined as:
764764// F(<u,u'>) = < f(u), f'(u)*u' >
765765template <class T , int P>
766- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
766+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
767767dualfunc (const Dual<T,P>& u, const T& f_val, const T& df_val)
768768{
769769 Dual<T,P> result;
@@ -781,7 +781,7 @@ dualfunc (const Dual<T,P>& u, const T& f_val, const T& df_val)
781781// F(<u,u'>, <v,v'>) = < f(u,v), dfdu(u,v)u' + dfdv(u,v)v' >
782782// (from http://en.wikipedia.org/wiki/Automatic_differentiation)
783783template <class T , int P>
784- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
784+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
785785dualfunc (const Dual<T,P>& u, const Dual<T,P>& v,
786786 const T& f_val, const T& dfdu_val, const T& dfdv_val)
787787{
@@ -796,7 +796,7 @@ dualfunc (const Dual<T,P>& u, const Dual<T,P>& v,
796796
797797// Helper for construction the result of a Dual function of three variables.
798798template <class T , int P>
799- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P>
799+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P>
800800dualfunc (const Dual<T,P>& u, const Dual<T,P>& v, const Dual<T,P>& w,
801801 const T& f_val, const T& dfdu_val, const T& dfdv_val, const T& dfdw_val)
802802{
@@ -815,7 +815,7 @@ dualfunc (const Dual<T,P>& u, const Dual<T,P>& v, const Dual<T,P>& w,
815815// / OIIO's fast_math.h fast_neg for a more full explanation of why this is
816816// / faster.
817817template <class T , int P>
818- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> fast_neg (const Dual<T,P> &a)
818+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> fast_neg (const Dual<T,P> &a)
819819{
820820 Dual<T,P> result;
821821 OSL_INDEX_LOOP (i, P+1 , {
@@ -1210,7 +1210,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> fast_erfc(const Dual<T,P> &a)
12101210
12111211// f(x) = sqrt(x), f'(x) = 1/(2*sqrt(x))
12121212template <class T , int P>
1213- OSL_HOSTDEVICE OSL_FORCEINLINE OSL_CONSTEXPR14 Dual<T,P> sqrt (const Dual<T,P> &a)
1213+ OSL_HOSTDEVICE OSL_FORCEINLINE constexpr Dual<T,P> sqrt (const Dual<T,P> &a)
12141214{
12151215 Dual<T,P> result;
12161216 if (OSL_LIKELY (a.val () > T (0 ))) {
@@ -1336,7 +1336,7 @@ OSL_HOSTDEVICE OSL_FORCEINLINE Dual<T,P> smoothstep (const Dual<T,P> &e0, const
13361336
13371337
13381338#ifdef __CUDA_ARCH__
1339- template <> inline OSL_HOSTDEVICE OSL_CONSTEXPR14 float3 Dual<float3, 2 >::zero() {
1339+ template <> inline OSL_HOSTDEVICE constexpr float3 Dual<float3, 2 >::zero() {
13401340 return float3{0 .f , 0 .f , 0 .f };
13411341}
13421342#endif
0 commit comments