Skip to content

Commit 7f41d96

Browse files
committed
Add optimized noise implementation from Intel for AVX2/FMA3-capable CPUs.
Also overhauled optimized noise for AVX/FMA4-capable CPUs, as well as CPU type identification code.
1 parent 9cf8a79 commit 7f41d96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4173
-1675
lines changed

platform/x86/avx2fma3noise.cpp

Lines changed: 512 additions & 0 deletions
Large diffs are not rendered by default.

platform/x86/avx2fma3noise.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//******************************************************************************
2+
///
3+
/// @file platform/x86/avx2fma3noise.h
4+
///
5+
/// This file contains declarations related to implementations of the noise
6+
/// generator optimized for the AVX2 and FMA3 instruction set.
7+
///
8+
/// @copyright
9+
/// @parblock
10+
///
11+
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
12+
/// Copyright 1991-2015 Persistence of Vision Raytracer Pty. Ltd.
13+
///
14+
/// POV-Ray is free software: you can redistribute it and/or modify
15+
/// it under the terms of the GNU Affero General Public License as
16+
/// published by the Free Software Foundation, either version 3 of the
17+
/// License, or (at your option) any later version.
18+
///
19+
/// POV-Ray is distributed in the hope that it will be useful,
20+
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
/// GNU Affero General Public License for more details.
23+
///
24+
/// You should have received a copy of the GNU Affero General Public License
25+
/// along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
///
27+
/// ----------------------------------------------------------------------------
28+
///
29+
/// POV-Ray is based on the popular DKB raytracer version 2.12.
30+
/// DKBTrace was originally written by David K. Buck.
31+
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
32+
///
33+
/// @endparblock
34+
///
35+
//******************************************************************************
36+
37+
#ifndef POVRAY_AVX2FMA3NOISE_H
38+
#define POVRAY_AVX2FMA3NOISE_H
39+
40+
#include "syspovconfigbase.h"
41+
#include "backend/frame.h"
42+
43+
#ifdef TRY_OPTIMIZED_NOISE_AVX2FMA3
44+
45+
namespace pov
46+
{
47+
48+
bool AVX2FMA3NoiseSupported();
49+
50+
void AVX2FMA3NoiseInit();
51+
52+
/// Optimized Noise function using AVX2 and FMA3 instructions.
53+
/// @author Optimized by Intel
54+
DBL AVX2FMA3Noise(const Vector3d& EPoint, int noise_generator);
55+
56+
/// Optimized DNoise function using AVX2 and FMA3 instructions.
57+
/// @author Optimized by Intel
58+
void AVX2FMA3DNoise(Vector3d& result, const Vector3d& EPoint);
59+
60+
}
61+
62+
#endif // TRY_OPTIMIZED_NOISE_AVX2FMA3
63+
64+
#endif // POVRAY_AVX2FMA3NOISE_H

platform/x86/avxfma4noise.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/// This file contains implementations of the noise generator optimized for the
66
/// AVX and FMA4 instruction set.
77
///
8+
/// @author Original optimizations by AMD
9+
///
810
/// @copyright
911
/// @parblock
1012
///
@@ -37,13 +39,17 @@
3739
#include "syspovconfigbase.h"
3840
#include "avxfma4noise.h"
3941

42+
#ifdef MACHINE_INTRINSICS_H
43+
#include MACHINE_INTRINSICS_H
44+
#endif
45+
4046
#include "core/material/pattern.h"
4147
#include "core/material/texture.h"
4248
#include "cpuid.h"
4349

4450
/*****************************************************************************/
4551

46-
#ifdef TRY_OPTIMIZED_NOISE
52+
#ifdef TRY_OPTIMIZED_NOISE_AVXFMA4
4753

4854
/********************************************************************************************/
4955
/* AMD Specific optimizations: Its found that more than 50% of the time is spent in */
@@ -688,5 +694,5 @@ void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint)
688694

689695
}
690696

691-
#endif
697+
#endif // TRY_OPTIMIZED_NOISE_AVXFMA4
692698

platform/x86/avxfma4noise.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "syspovconfigbase.h"
4141
#include "backend/frame.h"
4242

43-
#ifdef TRY_OPTIMIZED_NOISE
43+
#ifdef TRY_OPTIMIZED_NOISE_AVXFMA4
4444

4545
namespace pov
4646
{
@@ -58,6 +58,6 @@ void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint);
5858

5959
}
6060

61-
#endif // TRY_OPTIMIZED_NOISE
61+
#endif // TRY_OPTIMIZED_NOISE_AVXFMA4
6262

6363
#endif // POVRAY_AVXFMA4NOISE_H

0 commit comments

Comments
 (0)