Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
e0d28c16
Commit
e0d28c16
authored
Apr 21, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a simple profiling test.
parent
f94f7e76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
9 deletions
+167
-9
tests/mal_profiling.c
tests/mal_profiling.c
+158
-0
tests/mal_test_0.vcxproj
tests/mal_test_0.vcxproj
+9
-9
No files found.
tests/mal_profiling.c
View file @
e0d28c16
#define MAL_IMPLEMENTATION
#define MAL_IMPLEMENTATION
#include "../mini_al.h"
#include "../mini_al.h"
float
g_ChannelRouterProfilingOutputBenchmark
[
8
][
480000
];
float
g_ChannelRouterProfilingOutput
[
8
][
480000
];
double
g_ChannelRouterTime_Reference
=
0
;
double
g_ChannelRouterTime_SSE2
=
0
;
double
g_ChannelRouterTime_AVX
=
0
;
double
g_ChannelRouterTime_AVX512
=
0
;
double
g_ChannelRouterTime_NEON
=
0
;
mal_sine_wave
sineWave
;
mal_bool32
channel_router_test
(
mal_uint32
channels
,
mal_uint64
frameCount
,
float
**
ppFramesA
,
float
**
ppFramesB
)
{
for
(
mal_uint32
iChannel
=
0
;
iChannel
<
channels
;
++
iChannel
)
{
for
(
mal_uint32
iFrame
=
0
;
iFrame
<
frameCount
;
++
iFrame
)
{
if
(
ppFramesA
[
iChannel
][
iFrame
]
!=
ppFramesB
[
iChannel
][
iFrame
])
{
return
MAL_FALSE
;
}
}
}
return
MAL_TRUE
;
}
mal_uint32
channel_router_on_read
(
mal_channel_router
*
pRouter
,
mal_uint32
frameCount
,
void
**
ppSamplesOut
,
void
*
pUserData
)
{
(
void
)
pUserData
;
(
void
)
pRouter
;
float
**
ppSamplesOutF
=
(
float
**
)
ppSamplesOut
;
for
(
mal_uint32
iChannel
=
0
;
iChannel
<
pRouter
->
config
.
channelsIn
;
++
iChannel
)
{
mal_sine_wave_init
(
1
/
(
iChannel
+
1
),
400
,
48000
,
&
sineWave
);
mal_sine_wave_read
(
&
sineWave
,
frameCount
,
ppSamplesOutF
[
iChannel
]);
}
return
frameCount
;
}
int
do_profiling__channel_routing
()
int
do_profiling__channel_routing
()
{
{
mal_result
result
;
// When profiling we need to compare against a benchmark to ensure the optimization is implemented correctly. We always
// use the reference implementation for our benchmark.
mal_uint32
channels
=
mal_countof
(
g_ChannelRouterProfilingOutputBenchmark
);
mal_channel
channelMapIn
[
MAL_MAX_CHANNELS
];
mal_get_standard_channel_map
(
mal_standard_channel_map_default
,
channels
,
channelMapIn
);
mal_channel
channelMapOut
[
MAL_MAX_CHANNELS
];
mal_get_standard_channel_map
(
mal_standard_channel_map_default
,
channels
,
channelMapOut
);
mal_channel_router_config
routerConfig
=
mal_channel_router_config_init
(
channels
,
channelMapIn
,
channels
,
channelMapOut
,
mal_channel_mix_mode_planar_blend
,
channel_router_on_read
,
NULL
);
mal_channel_router
router
;
result
=
mal_channel_router_init
(
&
routerConfig
,
&
router
);
if
(
result
!=
MAL_SUCCESS
)
{
return
-
1
;
}
// Disable optimizations for our tests.
router
.
isPassthrough
=
MAL_FALSE
;
router
.
isSimpleShuffle
=
MAL_FALSE
;
router
.
useSSE2
=
MAL_FALSE
;
router
.
useAVX
=
MAL_FALSE
;
router
.
useAVX512
=
MAL_FALSE
;
router
.
useNEON
=
MAL_FALSE
;
mal_uint64
framesToRead
=
mal_countof
(
g_ChannelRouterProfilingOutputBenchmark
[
0
]);
// Benchmark
void
*
ppOutBenchmark
[
8
];
for
(
int
i
=
0
;
i
<
8
;
++
i
)
{
ppOutBenchmark
[
i
]
=
(
void
*
)
g_ChannelRouterProfilingOutputBenchmark
[
i
];
}
mal_sine_wave_init
(
1
,
400
,
48000
,
&
sineWave
);
mal_uint64
framesRead
=
mal_channel_router_read_deinterleaved
(
&
router
,
framesToRead
,
ppOutBenchmark
,
NULL
);
if
(
framesRead
!=
framesToRead
)
{
printf
(
"Channel Router: An error occurred while reading benchmark data.
\n
"
);
}
void
*
ppOut
[
8
];
for
(
int
i
=
0
;
i
<
8
;
++
i
)
{
ppOut
[
i
]
=
(
void
*
)
g_ChannelRouterProfilingOutput
[
i
];
}
printf
(
"Channel Routing
\n
"
);
printf
(
"===============
\n
"
);
// Reference
{
mal_timer
timer
;
mal_timer_init
(
&
timer
);
double
startTime
=
mal_timer_get_time_in_seconds
(
&
timer
);
framesRead
=
mal_channel_router_read_deinterleaved
(
&
router
,
framesToRead
,
ppOut
,
NULL
);
if
(
framesRead
!=
framesToRead
)
{
printf
(
"Channel Router: An error occurred while reading reference data.
\n
"
);
}
if
(
!
channel_router_test
(
channels
,
framesRead
,
(
float
**
)
ppOutBenchmark
,
(
float
**
)
ppOut
))
{
printf
(
" [ERROR] "
);
}
else
{
printf
(
" [PASSED] "
);
}
g_ChannelRouterTime_Reference
=
mal_timer_get_time_in_seconds
(
&
timer
)
-
startTime
;
printf
(
"Reference: %.4fms (%.2f%%)
\n
"
,
g_ChannelRouterTime_Reference
*
1000
,
g_ChannelRouterTime_Reference
/
g_ChannelRouterTime_Reference
*
100
);
}
// SSE2
if
(
mal_has_sse2
())
{
router
.
useSSE2
=
MAL_TRUE
;
mal_timer
timer
;
mal_timer_init
(
&
timer
);
double
startTime
=
mal_timer_get_time_in_seconds
(
&
timer
);
framesRead
=
mal_channel_router_read_deinterleaved
(
&
router
,
framesToRead
,
ppOut
,
NULL
);
if
(
framesRead
!=
framesToRead
)
{
printf
(
"Channel Router: An error occurred while reading SSE2 data.
\n
"
);
}
g_ChannelRouterTime_SSE2
=
mal_timer_get_time_in_seconds
(
&
timer
)
-
startTime
;
router
.
useSSE2
=
MAL_FALSE
;
if
(
!
channel_router_test
(
channels
,
framesRead
,
(
float
**
)
ppOutBenchmark
,
(
float
**
)
ppOut
))
{
printf
(
" [ERROR] "
);
}
else
{
printf
(
" [PASSED] "
);
}
printf
(
"SSE2: %.4fms (%.2f%%)
\n
"
,
g_ChannelRouterTime_SSE2
*
1000
,
g_ChannelRouterTime_Reference
/
g_ChannelRouterTime_SSE2
*
100
);
}
// AVX
if
(
mal_has_avx
())
{
router
.
useAVX
=
MAL_TRUE
;
mal_timer
timer
;
mal_timer_init
(
&
timer
);
double
startTime
=
mal_timer_get_time_in_seconds
(
&
timer
);
framesRead
=
mal_channel_router_read_deinterleaved
(
&
router
,
framesToRead
,
ppOut
,
NULL
);
if
(
framesRead
!=
framesToRead
)
{
printf
(
"Channel Router: An error occurred while reading AVX data.
\n
"
);
}
g_ChannelRouterTime_AVX
=
mal_timer_get_time_in_seconds
(
&
timer
)
-
startTime
;
router
.
useAVX
=
MAL_FALSE
;
if
(
!
channel_router_test
(
channels
,
framesRead
,
(
float
**
)
ppOutBenchmark
,
(
float
**
)
ppOut
))
{
printf
(
" [ERROR] "
);
}
else
{
printf
(
" [PASSED] "
);
}
printf
(
"AVX: %.4fms (%.2f%%)
\n
"
,
g_ChannelRouterTime_AVX
*
1000
,
g_ChannelRouterTime_Reference
/
g_ChannelRouterTime_AVX
*
100
);
}
return
1
;
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
...
@@ -14,5 +170,7 @@ int main(int argc, char** argv)
...
@@ -14,5 +170,7 @@ int main(int argc, char** argv)
// Channel routing.
// Channel routing.
do_profiling__channel_routing
();
do_profiling__channel_routing
();
getchar
();
return
0
;
return
0
;
}
}
\ No newline at end of file
tests/mal_test_0.vcxproj
View file @
e0d28c16
...
@@ -259,21 +259,21 @@
...
@@ -259,21 +259,21 @@
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ItemGroup>
<ClCompile
Include=
"mal_profiling.c"
>
<ClCompile
Include=
"mal_profiling.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
true
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"mal_test_0.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
false
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
false
</ExcludedFromBuild>
</ClCompile>
</ClCompile>
<ClCompile
Include=
"mal_test_0.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|ARM'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
true
</ExcludedFromBuild>
</ClCompile>
<ClCompile
Include=
"mal_test_0.cpp"
>
<ClCompile
Include=
"mal_test_0.cpp"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
true
</ExcludedFromBuild>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|ARM'"
>
true
</ExcludedFromBuild>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment