-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from toxa81/develop
fixes
- Loading branch information
Showing
10 changed files
with
213 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include <sirius.h> | ||
|
||
using namespace sirius; | ||
|
||
void test1() | ||
{ | ||
memory_pool mp; | ||
} | ||
|
||
void test2() | ||
{ | ||
memory_pool mp; | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.reset<memory_t::host>(); | ||
} | ||
|
||
void test3() | ||
{ | ||
memory_pool mp; | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.allocate<double_complex, memory_t::host>(2024); | ||
mp.allocate<double_complex, memory_t::host>(3024); | ||
mp.reset<memory_t::host>(); | ||
} | ||
|
||
void test4() | ||
{ | ||
memory_pool mp; | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.reset<memory_t::host>(); | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.reset<memory_t::host>(); | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.allocate<double_complex, memory_t::host>(1024); | ||
mp.reset<memory_t::host>(); | ||
} | ||
|
||
void test5() | ||
{ | ||
memory_pool mp; | ||
|
||
for (int k = 0; k < 2; k++) { | ||
std::vector<double*> vp; | ||
for (size_t i = 1; i < 20; i++) { | ||
size_t sz = 1 << i; | ||
double* ptr = mp.allocate<double, memory_t::host>(sz); | ||
ptr[0] = 0; | ||
ptr[sz - 1] = 0; | ||
vp.push_back(ptr); | ||
} | ||
for (auto& e: vp) { | ||
mp.free<memory_t::host>(e); | ||
} | ||
} | ||
} | ||
|
||
int run_test() | ||
{ | ||
test1(); | ||
test2(); | ||
test3(); | ||
test4(); | ||
test5(); | ||
return 0; | ||
} | ||
|
||
int main(int argn, char** argv) | ||
{ | ||
cmd_args args; | ||
|
||
args.parse_args(argn, argv); | ||
if (args.exist("help")) { | ||
printf("Usage: %s [options]\n", argv[0]); | ||
args.print_help(); | ||
return 0; | ||
} | ||
|
||
sirius::initialize(1); | ||
printf("%-30s", "testing memory pool: "); | ||
int result = run_test(); | ||
if (result) { | ||
printf("\x1b[31m" "Failed" "\x1b[0m" "\n"); | ||
} else { | ||
printf("\x1b[32m" "OK" "\x1b[0m" "\n"); | ||
} | ||
sirius::finalize(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
|
||
namespace sddk { | ||
|
||
/// Simple profiler and function call tracker. | ||
class profiler | ||
{ | ||
private: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.