Skip to content

Commit 813cb9d

Browse files
committed
hacky fillbuffer benchmarks
1 parent 259843d commit 813cb9d

1 file changed

Lines changed: 149 additions & 2 deletions

File tree

  • samples/benchmarks/00_apibenchmark

samples/benchmarks/00_apibenchmark/main.cpp

Lines changed: 149 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,6 @@ BENCHMARK_REGISTER_F(SVMKernel, clSetKernelArgSVMPointer)->Arg(1)->Arg(2)->Arg(4
405405

406406
struct USMMemCpy : public benchmark::Fixture
407407
{
408-
bool hasSupport = false;
409-
410408
cl::CommandQueue queue;
411409

412410
std::vector<void*> dptrs;
@@ -456,6 +454,155 @@ BENCHMARK_DEFINE_F(USMMemCpy, clEnqueueMemcpyINTEL_device_blocking)(benchmark::S
456454
}
457455
BENCHMARK_REGISTER_F(USMMemCpy, clEnqueueMemcpyINTEL_device_blocking);
458456

457+
struct USMMemFill : public benchmark::Fixture
458+
{
459+
const size_t sz = 1 * 1024 * 1024;
460+
461+
cl::CommandQueue queue;
462+
463+
void* dptr = NULL;
464+
void* hptr = NULL;
465+
void* sptr = NULL;
466+
467+
virtual void SetUp(benchmark::State& state) override {
468+
queue = env.ioq;
469+
470+
dptr = clDeviceMemAllocINTEL(env.context(), env.device(), NULL, sz, 0, NULL);
471+
hptr = clHostMemAllocINTEL(env.context(), NULL, sz, 0, NULL);
472+
sptr = clSharedMemAllocINTEL(env.context(), env.device(), NULL, sz, 0, NULL);
473+
}
474+
virtual void TearDown(benchmark::State& state) override {
475+
queue = NULL;
476+
477+
clMemBlockingFreeINTEL(env.context(), dptr);
478+
clMemBlockingFreeINTEL(env.context(), hptr);
479+
clMemBlockingFreeINTEL(env.context(), sptr);
480+
}
481+
};
482+
483+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemsetINTEL_dptr)(benchmark::State& state)
484+
{
485+
if (dptr == NULL) {
486+
state.SkipWithError("unsupported");
487+
}
488+
for(auto _ : state) {
489+
clEnqueueMemsetINTEL(
490+
queue(),
491+
dptr,
492+
0,
493+
sz,
494+
0,
495+
NULL,
496+
NULL);
497+
queue.finish();
498+
}
499+
}
500+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemsetINTEL_dptr);
501+
502+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemsetINTEL_hptr)(benchmark::State& state)
503+
{
504+
if (hptr == NULL) {
505+
state.SkipWithError("unsupported");
506+
}
507+
for(auto _ : state) {
508+
clEnqueueMemsetINTEL(
509+
queue(),
510+
hptr,
511+
0,
512+
sz,
513+
0,
514+
NULL,
515+
NULL);
516+
queue.finish();
517+
}
518+
}
519+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemsetINTEL_hptr);
520+
521+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemsetINTEL_sptr)(benchmark::State& state)
522+
{
523+
if (sptr == NULL) {
524+
state.SkipWithError("unsupported");
525+
}
526+
for(auto _ : state) {
527+
clEnqueueMemsetINTEL(
528+
queue(),
529+
sptr,
530+
0,
531+
sz,
532+
0,
533+
NULL,
534+
NULL);
535+
queue.finish();
536+
}
537+
}
538+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemsetINTEL_sptr);
539+
540+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemFillINTEL_dptr)(benchmark::State& state)
541+
{
542+
if (dptr == NULL) {
543+
state.SkipWithError("unsupported");
544+
}
545+
const cl_ulong pattern = 0;
546+
const size_t patternSize = state.range(0);
547+
for(auto _ : state) {
548+
clEnqueueMemFillINTEL(
549+
queue(),
550+
dptr,
551+
&pattern,
552+
patternSize,
553+
sz,
554+
0,
555+
NULL,
556+
NULL);
557+
queue.finish();
558+
}
559+
}
560+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemFillINTEL_dptr)->Arg(1)->Arg(4)->Arg(8);
561+
562+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemFillINTEL_hptr)(benchmark::State& state)
563+
{
564+
if (hptr == NULL) {
565+
state.SkipWithError("unsupported");
566+
}
567+
const cl_ulong pattern = 0;
568+
const size_t patternSize = state.range(0);
569+
for(auto _ : state) {
570+
clEnqueueMemFillINTEL(
571+
queue(),
572+
hptr,
573+
&pattern,
574+
patternSize,
575+
sz,
576+
0,
577+
NULL,
578+
NULL);
579+
queue.finish();
580+
}
581+
}
582+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemFillINTEL_hptr)->Arg(1)->Arg(4)->Arg(8);
583+
584+
BENCHMARK_DEFINE_F(USMMemFill, clEnqueueMemFillINTEL_sptr)(benchmark::State& state)
585+
{
586+
if (sptr == NULL) {
587+
state.SkipWithError("unsupported");
588+
}
589+
const cl_ulong pattern = 0;
590+
const size_t patternSize = state.range(0);
591+
for(auto _ : state) {
592+
clEnqueueMemFillINTEL(
593+
queue(),
594+
sptr,
595+
&pattern,
596+
patternSize,
597+
sz,
598+
0,
599+
NULL,
600+
NULL);
601+
queue.finish();
602+
}
603+
}
604+
BENCHMARK_REGISTER_F(USMMemFill, clEnqueueMemFillINTEL_sptr)->Arg(1)->Arg(4)->Arg(8);
605+
459606
int main(int argc, char** argv)
460607
{
461608
env.ParseArgs(argc, argv);

0 commit comments

Comments
 (0)