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
9245dce6
Commit
9245dce6
authored
Apr 08, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prep work for some SIMD optimizations.
parent
e7bc174b
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
317 additions
and
75 deletions
+317
-75
mini_al.h
mini_al.h
+155
-75
tests/mal_test_0.c
tests/mal_test_0.c
+162
-0
No files found.
mini_al.h
View file @
9245dce6
This diff is collapsed.
Click to expand it.
tests/mal_test_0.c
View file @
9245dce6
...
...
@@ -96,6 +96,158 @@ void* open_and_read_file_data(const char* filePath, size_t* pSizeOut)
return
pFileData
;
}
int
do_types_tests
()
{
int
result
=
0
;
int
sizeof_int8
=
sizeof
(
mal_int8
);
int
sizeof_uint8
=
sizeof
(
mal_uint8
);
int
sizeof_int16
=
sizeof
(
mal_int16
);
int
sizeof_uint16
=
sizeof
(
mal_uint16
);
int
sizeof_int32
=
sizeof
(
mal_int32
);
int
sizeof_uint32
=
sizeof
(
mal_uint32
);
int
sizeof_int64
=
sizeof
(
mal_int64
);
int
sizeof_uint64
=
sizeof
(
mal_uint64
);
int
sizeof_float32
=
sizeof
(
float
);
int
sizeof_float64
=
sizeof
(
double
);
int
sizeof_uintptr
=
sizeof
(
mal_uintptr
);
printf
(
"sizeof(mal_int8) 1 = %d"
,
sizeof_int8
);
if
(
sizeof_int8
!=
1
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_uint8) 1 = %d"
,
sizeof_uint8
);
if
(
sizeof_uint8
!=
1
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_int16) 2 = %d"
,
sizeof_int16
);
if
(
sizeof_int16
!=
2
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_uint16) 2 = %d"
,
sizeof_uint16
);
if
(
sizeof_uint16
!=
2
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_int32) 4 = %d"
,
sizeof_int32
);
if
(
sizeof_int32
!=
4
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_uint32) 4 = %d"
,
sizeof_uint32
);
if
(
sizeof_uint32
!=
4
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_int64) 8 = %d"
,
sizeof_int64
);
if
(
sizeof_int64
!=
8
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_uint64) 8 = %d"
,
sizeof_uint64
);
if
(
sizeof_uint64
!=
8
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(float) 4 = %d"
,
sizeof_float32
);
if
(
sizeof_float32
!=
4
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(double) 8 = %d"
,
sizeof_float64
);
if
(
sizeof_float64
!=
8
)
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
printf
(
"sizeof(mal_uintptr) %d = %d"
,
(
int
)
sizeof
(
void
*
),
sizeof_uintptr
);
if
(
sizeof_uintptr
!=
sizeof
(
void
*
))
{
printf
(
" - FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
" - PASSED
\n
"
);
}
return
result
;
}
int
do_aligned_malloc_tests
()
{
int
result
=
0
;
// We just do a whole bunch of malloc's and check them. This can probably be made more exhaustive.
void
*
p
[
1024
];
for
(
mal_uint32
i
=
0
;
i
<
mal_countof
(
p
);
++
i
)
{
mal_uintptr
alignment
=
MAL_SIMD_ALIGNMENT
;
p
[
i
]
=
mal_aligned_malloc
(
1024
,
alignment
);
if
(((
mal_uintptr
)
p
[
i
]
&
(
alignment
-
1
))
!=
0
)
{
printf
(
"FAILED
\n
"
);
result
=
-
1
;
}
}
// Free.
for
(
mal_uint32
i
=
0
;
i
<
mal_countof
(
p
);
++
i
)
{
mal_aligned_free
(
p
[
i
]);
}
if
(
result
==
0
)
{
printf
(
"PASSED
\n
"
);
}
return
result
;
}
int
do_core_tests
()
{
int
result
=
0
;
printf
(
"Types...
\n
"
);
if
(
do_types_tests
()
!=
0
)
{
printf
(
"FAILED
\n
"
);
result
=
-
1
;
}
else
{
printf
(
"PASSED
\n
"
);
}
printf
(
"Aligned malloc... "
);
if
(
do_aligned_malloc_tests
()
!=
0
)
{
result
=
-
1
;
}
return
result
;
}
void
*
load_raw_audio_data
(
const
char
*
filePath
,
mal_format
format
,
mal_uint64
*
pBenchmarkFrameCount
)
{
mal_assert
(
pBenchmarkFrameCount
!=
NULL
);
...
...
@@ -2130,6 +2282,16 @@ int main(int argc, char** argv)
mal_bool32
hasErrorOccurred
=
MAL_FALSE
;
int
result
=
0
;
// Aligned malloc/free
printf
(
"=== TESTING CORE ===
\n
"
);
result
=
do_core_tests
();
if
(
result
<
0
)
{
hasErrorOccurred
=
MAL_TRUE
;
}
printf
(
"=== END TESTING CORE ===
\n
"
);
printf
(
"
\n
"
);
// Format Conversion
printf
(
"=== TESTING FORMAT CONVERSION ===
\n
"
);
result
=
do_format_conversion_tests
();
...
...
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