Skip to content

Commit 69ea26a

Browse files
Add tests for DPCTLQueue_FillNWithEvents
1 parent e31f905 commit 69ea26a

1 file changed

Lines changed: 224 additions & 0 deletions

File tree

‎libsyclinterface/tests/test_sycl_queue_interface.cpp‎

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,26 @@ TEST(TestDPCTLSyclQueueInterface, CheckFillNullQRef)
559559

560560
ASSERT_NO_FATAL_FAILURE(ERef = DPCTLQueue_Fill128(QRef, p, val128, 1));
561561
ASSERT_FALSE(bool(ERef));
562+
563+
ASSERT_NO_FATAL_FAILURE(
564+
ERef = DPCTLQueue_Fill8WithEvents(QRef, p, val8, 1, nullptr, 0));
565+
ASSERT_FALSE(bool(ERef));
566+
567+
ASSERT_NO_FATAL_FAILURE(
568+
ERef = DPCTLQueue_Fill16WithEvents(QRef, p, val16, 1, nullptr, 0));
569+
ASSERT_FALSE(bool(ERef));
570+
571+
ASSERT_NO_FATAL_FAILURE(
572+
ERef = DPCTLQueue_Fill32WithEvents(QRef, p, val32, 1, nullptr, 0));
573+
ASSERT_FALSE(bool(ERef));
574+
575+
ASSERT_NO_FATAL_FAILURE(
576+
ERef = DPCTLQueue_Fill64WithEvents(QRef, p, val64, 1, nullptr, 0));
577+
ASSERT_FALSE(bool(ERef));
578+
579+
ASSERT_NO_FATAL_FAILURE(
580+
ERef = DPCTLQueue_Fill128WithEvents(QRef, p, val128, 1, nullptr, 0));
581+
ASSERT_FALSE(bool(ERef));
562582
}
563583

564584
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill8)
@@ -751,6 +771,210 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckFill128)
751771
delete[] host_arr;
752772
}
753773

774+
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill8WithEvents)
775+
{
776+
using T = uint8_t;
777+
DPCTLSyclUSMRef p = nullptr;
778+
DPCTLSyclEventRef FillDep_ERef = nullptr;
779+
DPCTLSyclEventRef Fill_ERef = nullptr;
780+
DPCTLSyclEventRef Memcpy_ERef = nullptr;
781+
T val = static_cast<T>(0xB);
782+
size_t nelems = 256;
783+
T *host_arr = new T[nelems];
784+
size_t nbytes = nelems * sizeof(T);
785+
786+
ASSERT_FALSE(host_arr == nullptr);
787+
788+
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
789+
ASSERT_FALSE(p == nullptr);
790+
791+
ASSERT_NO_FATAL_FAILURE(FillDep_ERef =
792+
DPCTLQueue_Fill8(QRef, (void *)p, 0, nelems));
793+
794+
ASSERT_NO_FATAL_FAILURE(
795+
Fill_ERef = DPCTLQueue_Fill8WithEvents(QRef, (void *)p, val, nelems,
796+
&FillDep_ERef, 1));
797+
798+
ASSERT_NO_FATAL_FAILURE(Memcpy_ERef = DPCTLQueue_MemcpyWithEvents(
799+
QRef, host_arr, p, nbytes, &Fill_ERef, 1));
800+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Wait(Memcpy_ERef));
801+
802+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(FillDep_ERef));
803+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Fill_ERef));
804+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Memcpy_ERef));
805+
806+
ASSERT_NO_FATAL_FAILURE(DPCTLfree_with_queue(p, QRef));
807+
808+
for (size_t i = 0; i < nelems; ++i) {
809+
ASSERT_TRUE(host_arr[i] == val);
810+
}
811+
delete[] host_arr;
812+
}
813+
814+
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill16WithEvents)
815+
{
816+
using T = uint16_t;
817+
DPCTLSyclUSMRef p = nullptr;
818+
DPCTLSyclEventRef FillDep_ERef = nullptr;
819+
DPCTLSyclEventRef Fill_ERef = nullptr;
820+
DPCTLSyclEventRef Memcpy_ERef = nullptr;
821+
T val = static_cast<T>(0xAB);
822+
size_t nelems = 256;
823+
T *host_arr = new T[nelems];
824+
size_t nbytes = nelems * sizeof(T);
825+
826+
ASSERT_FALSE(host_arr == nullptr);
827+
828+
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
829+
ASSERT_FALSE(p == nullptr);
830+
831+
ASSERT_NO_FATAL_FAILURE(FillDep_ERef =
832+
DPCTLQueue_Fill16(QRef, (void *)p, 0, nelems));
833+
834+
ASSERT_NO_FATAL_FAILURE(
835+
Fill_ERef = DPCTLQueue_Fill16WithEvents(QRef, (void *)p, val, nelems,
836+
&FillDep_ERef, 1));
837+
838+
ASSERT_NO_FATAL_FAILURE(Memcpy_ERef = DPCTLQueue_MemcpyWithEvents(
839+
QRef, host_arr, p, nbytes, &Fill_ERef, 1));
840+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Wait(Memcpy_ERef));
841+
842+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(FillDep_ERef));
843+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Fill_ERef));
844+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Memcpy_ERef));
845+
846+
ASSERT_NO_FATAL_FAILURE(DPCTLfree_with_queue(p, QRef));
847+
848+
for (size_t i = 0; i < nelems; ++i) {
849+
ASSERT_TRUE(host_arr[i] == val);
850+
}
851+
delete[] host_arr;
852+
}
853+
854+
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill32WithEvents)
855+
{
856+
using T = uint32_t;
857+
DPCTLSyclUSMRef p = nullptr;
858+
DPCTLSyclEventRef FillDep_ERef = nullptr;
859+
DPCTLSyclEventRef Fill_ERef = nullptr;
860+
DPCTLSyclEventRef Memcpy_ERef = nullptr;
861+
T val = static_cast<T>(0xABCD);
862+
size_t nelems = 256;
863+
T *host_arr = new T[nelems];
864+
size_t nbytes = nelems * sizeof(T);
865+
866+
ASSERT_FALSE(host_arr == nullptr);
867+
868+
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
869+
ASSERT_FALSE(p == nullptr);
870+
871+
ASSERT_NO_FATAL_FAILURE(FillDep_ERef =
872+
DPCTLQueue_Fill32(QRef, (void *)p, 0, nelems));
873+
874+
ASSERT_NO_FATAL_FAILURE(
875+
Fill_ERef = DPCTLQueue_Fill32WithEvents(QRef, (void *)p, val, nelems,
876+
&FillDep_ERef, 1));
877+
878+
ASSERT_NO_FATAL_FAILURE(Memcpy_ERef = DPCTLQueue_MemcpyWithEvents(
879+
QRef, host_arr, p, nbytes, &Fill_ERef, 1));
880+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Wait(Memcpy_ERef));
881+
882+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(FillDep_ERef));
883+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Fill_ERef));
884+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Memcpy_ERef));
885+
886+
ASSERT_NO_FATAL_FAILURE(DPCTLfree_with_queue(p, QRef));
887+
888+
for (size_t i = 0; i < nelems; ++i) {
889+
ASSERT_TRUE(host_arr[i] == val);
890+
}
891+
delete[] host_arr;
892+
}
893+
894+
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill64WithEvents)
895+
{
896+
using T = uint64_t;
897+
DPCTLSyclUSMRef p = nullptr;
898+
DPCTLSyclEventRef FillDep_ERef = nullptr;
899+
DPCTLSyclEventRef Fill_ERef = nullptr;
900+
DPCTLSyclEventRef Memcpy_ERef = nullptr;
901+
T val = static_cast<T>(0xABCDEF73);
902+
size_t nelems = 256;
903+
T *host_arr = new T[nelems];
904+
size_t nbytes = nelems * sizeof(T);
905+
906+
ASSERT_FALSE(host_arr == nullptr);
907+
908+
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
909+
ASSERT_FALSE(p == nullptr);
910+
911+
ASSERT_NO_FATAL_FAILURE(FillDep_ERef =
912+
DPCTLQueue_Fill64(QRef, (void *)p, 0, nelems));
913+
914+
ASSERT_NO_FATAL_FAILURE(
915+
Fill_ERef = DPCTLQueue_Fill64WithEvents(QRef, (void *)p, val, nelems,
916+
&FillDep_ERef, 1));
917+
918+
ASSERT_NO_FATAL_FAILURE(Memcpy_ERef = DPCTLQueue_MemcpyWithEvents(
919+
QRef, host_arr, p, nbytes, &Fill_ERef, 1));
920+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Wait(Memcpy_ERef));
921+
922+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(FillDep_ERef));
923+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Fill_ERef));
924+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Memcpy_ERef));
925+
926+
ASSERT_NO_FATAL_FAILURE(DPCTLfree_with_queue(p, QRef));
927+
928+
for (size_t i = 0; i < nelems; ++i) {
929+
ASSERT_TRUE(host_arr[i] == val);
930+
}
931+
delete[] host_arr;
932+
}
933+
934+
TEST_P(TestDPCTLQueueMemberFunctions, CheckFill128WithEvents)
935+
{
936+
using T = value128_t;
937+
DPCTLSyclUSMRef p = nullptr;
938+
DPCTLSyclEventRef FillDep_ERef = nullptr;
939+
DPCTLSyclEventRef Fill_ERef = nullptr;
940+
DPCTLSyclEventRef Memcpy_ERef = nullptr;
941+
T val{static_cast<uint64_t>(0xABCDEF73), static_cast<uint64_t>(0x3746AF05)};
942+
T zero{};
943+
size_t nelems = 256;
944+
T *host_arr = new T[nelems];
945+
size_t nbytes = nelems * sizeof(T);
946+
947+
ASSERT_FALSE(host_arr == nullptr);
948+
949+
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
950+
ASSERT_FALSE(p == nullptr);
951+
952+
ASSERT_NO_FATAL_FAILURE(
953+
FillDep_ERef = DPCTLQueue_Fill128(
954+
QRef, (void *)p, reinterpret_cast<uint64_t *>(&zero), nelems));
955+
956+
ASSERT_NO_FATAL_FAILURE(Fill_ERef = DPCTLQueue_Fill128WithEvents(
957+
QRef, (void *)p,
958+
reinterpret_cast<uint64_t *>(&val), nelems,
959+
&FillDep_ERef, 1));
960+
961+
ASSERT_NO_FATAL_FAILURE(Memcpy_ERef = DPCTLQueue_MemcpyWithEvents(
962+
QRef, host_arr, p, nbytes, &Fill_ERef, 1));
963+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Wait(Memcpy_ERef));
964+
965+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(FillDep_ERef));
966+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Fill_ERef));
967+
ASSERT_NO_FATAL_FAILURE(DPCTLEvent_Delete(Memcpy_ERef));
968+
969+
ASSERT_NO_FATAL_FAILURE(DPCTLfree_with_queue(p, QRef));
970+
971+
for (size_t i = 0; i < nelems; ++i) {
972+
ASSERT_TRUE(host_arr[i].first == val.first);
973+
ASSERT_TRUE(host_arr[i].second == val.second);
974+
}
975+
delete[] host_arr;
976+
}
977+
754978
INSTANTIATE_TEST_SUITE_P(
755979
DPCTLQueueMemberFuncTests,
756980
TestDPCTLQueueMemberFunctions,

0 commit comments

Comments
 (0)