Fix type-related issues in dependent code. Remove hardcoded mjUSEDOUBLE. Add mjUSESINGLE compiler flag.
This CL does not change the default build behavior of MuJoCo. To use single-precision floating-point, build MuJoCo with `-DmjUSESINGLE`. PiperOrigin-RevId: 644782648 Change-Id: Ie815df9916798ca8054306437b39a33f84ce9e08
This commit is contained in:
committed by
Copybara-Service
parent
7bd7065e0e
commit
3f3b39bbb1
@@ -35,9 +35,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef mjUSEPLATFORMSIMD
|
||||
#if defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#if defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
#define mjUSEAVX
|
||||
#endif // defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#endif // defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
#endif // mjUSEPLATFORMSIMD
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "engine/engine_util_spatial.h"
|
||||
|
||||
#ifdef mjUSEPLATFORMSIMD
|
||||
#if defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#if defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
#define mjUSEAVX
|
||||
#include "immintrin.h"
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <mujoco/mjtnum.h>
|
||||
|
||||
#ifdef mjUSEPLATFORMSIMD
|
||||
#if defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#if defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
#define mjUSEAVX
|
||||
#include "immintrin.h"
|
||||
#endif
|
||||
@@ -609,7 +609,7 @@ void mju_addToScl(mjtNum* res, const mjtNum* vec, mjtNum scl, int n) {
|
||||
void mju_addScl(mjtNum* res, const mjtNum* vec1, const mjtNum* vec2, mjtNum scl, int n) {
|
||||
int i = 0;
|
||||
|
||||
#if defined(__AVX__) && defined(mjUSEAVX) && defined(mjUSEDOUBLE)
|
||||
#if defined(__AVX__) && defined(mjUSEAVX) && !defined(mjUSESINGLE)
|
||||
int n_4 = n - 4;
|
||||
|
||||
// vector part
|
||||
|
||||
@@ -26,7 +26,7 @@ extern "C" {
|
||||
|
||||
//------------------------------ standard library functions ----------------------------------------
|
||||
|
||||
#ifdef mjUSEDOUBLE
|
||||
#if !defined(mjUSESINGLE)
|
||||
#define mju_sqrt sqrt
|
||||
#define mju_exp exp
|
||||
#define mju_sin sin
|
||||
@@ -59,7 +59,7 @@ extern "C" {
|
||||
#define mju_log10 log10f
|
||||
#define mju_floor floorf
|
||||
#define mju_ceil ceilf
|
||||
#endif
|
||||
#endif // !defined(mjUSESINGLE)
|
||||
|
||||
|
||||
//------------------------------ 3D vector and matrix-vector operations ----------------------------
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define MUJOCO_SRC_ENGINE_ENGINE_UTIL_SPARSE_AVX_H_
|
||||
|
||||
#ifdef mjUSEPLATFORMSIMD
|
||||
#if defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#if defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
|
||||
#define mjUSEAVX
|
||||
|
||||
@@ -315,7 +315,7 @@ int mju_compare_avx(const int* vec1, const int* vec2, int n) {
|
||||
return !memcmp(vec1+i, vec2+i, (n-i)*sizeof(int));
|
||||
}
|
||||
|
||||
#endif // defined(__AVX__) && defined(mjUSEDOUBLE)
|
||||
#endif // defined(__AVX__) && !defined(mjUSESINGLE)
|
||||
|
||||
#endif // mjUSEPLATFORMSIMD
|
||||
|
||||
|
||||
Reference in New Issue
Block a user