diff options
Diffstat (limited to 'tests/validation/gpu/unit')
-rw-r--r-- | tests/validation/gpu/unit/Context.cpp | 76 | ||||
-rw-r--r-- | tests/validation/gpu/unit/Queue.cpp | 81 | ||||
-rw-r--r-- | tests/validation/gpu/unit/Tensor.cpp | 53 | ||||
-rw-r--r-- | tests/validation/gpu/unit/TensorPack.cpp | 47 |
4 files changed, 188 insertions, 69 deletions
diff --git a/tests/validation/gpu/unit/Context.cpp b/tests/validation/gpu/unit/Context.cpp index 06b4a83925..598e219fd9 100644 --- a/tests/validation/gpu/unit/Context.cpp +++ b/tests/validation/gpu/unit/Context.cpp @@ -21,11 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "tests/framework/Asserts.h" -#include "tests/framework/Macros.h" -#include "tests/validation/Validation.h" - -#include "arm_compute/Acl.hpp" +#include "tests/validation/fixtures/UNIT/ContextFixture.h" #include "src/gpu/cl/ClContext.h" @@ -41,67 +37,9 @@ TEST_SUITE(CL) TEST_SUITE(UNIT) TEST_SUITE(Context) -/** Test-case for AclCreateContext and AclDestroy Context - * - * Validate that AclCreateContext can create and destroy a context - * - * Test Steps: - * - Call AclCreateContext with valid target - * - Confirm that context is not nullptr and error code is AclSuccess - * - Destroy context - * - Confirm that AclSuccess is reported - */ -TEST_CASE(SimpleContextCApi, framework::DatasetMode::ALL) -{ - AclContext ctx = nullptr; - ARM_COMPUTE_ASSERT(AclCreateContext(&ctx, AclGpuOcl, nullptr) == AclStatus::AclSuccess); - ARM_COMPUTE_ASSERT(ctx != nullptr); - ARM_COMPUTE_ASSERT(AclDestroyContext(ctx) == AclStatus::AclSuccess); -} - -/** Test-case for Context from the C++ interface - * - * Test Steps: - * - Create a Context obejct - * - Confirm that StatusCode::Success is reported - * - Confirm that equality operator works - * - Confirm that inequality operator works - */ -TEST_CASE(SimpleContextCppApi, framework::DatasetMode::ALL) -{ - acl::StatusCode status = acl::StatusCode::Success; - acl::Context ctx(acl::Target::GpuOcl, &status); - ARM_COMPUTE_ASSERT(status == acl::StatusCode::Success); - - auto ctx_eq = ctx; - ARM_COMPUTE_ASSERT(ctx_eq == ctx); - - acl::Context ctx_ienq(acl::Target::GpuOcl, &status); - ARM_COMPUTE_ASSERT(status == acl::StatusCode::Success); - ARM_COMPUTE_ASSERT(ctx_ienq != ctx); -} - -/** Test-case for CpuCapabilities - * - * Validate that AclCreateContext can create/destroy multiple contexts with different options - * - * Test Steps: - * - Call AclCreateContext with different targets - * - Confirm that AclSuccess is reported - * - Destroy all contexts - * - Confirm that AclSuccess is reported - */ -TEST_CASE(MultipleContexts, framework::DatasetMode::ALL) -{ - const unsigned int num_tests = 5; - std::array<AclContext, num_tests> ctxs{}; - for(unsigned int i = 0; i < num_tests; ++i) - { - ARM_COMPUTE_ASSERT(AclCreateContext(&ctxs[i], AclTarget::AclGpuOcl, nullptr) == AclStatus::AclSuccess); - ARM_COMPUTE_ASSERT(ctxs[i] != nullptr); - ARM_COMPUTE_ASSERT(AclDestroyContext(ctxs[i]) == AclStatus::AclSuccess); - } -} +EMPTY_BODY_FIXTURE_TEST_CASE(SimpleContextCApi, SimpleContextCApiFixture<AclTarget::AclGpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(SimpleContextCppApi, SimpleContextCppApiFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(MultipleContexts, MultipleContextsFixture<AclTarget::AclGpuOcl>, framework::DatasetMode::ALL) /** Test-case for MLGO kernel configuration file * @@ -148,9 +86,9 @@ TEST_CASE(CheckMLGO, framework::DatasetMode::ALL) ofs << mlgo_str; ofs.close(); - AclContextOptions opts = acl_default_ctx_options; - opts.kernel_config_file = mlgo_filename.c_str(); - arm_compute::gpu::opencl::ClContext ctx(&opts); + acl::Context::Options opts; + opts.copts.kernel_config_file = mlgo_filename.c_str(); + arm_compute::gpu::opencl::ClContext ctx(&opts.copts); const MLGOHeuristics &heuristics = ctx.mlgo(); diff --git a/tests/validation/gpu/unit/Queue.cpp b/tests/validation/gpu/unit/Queue.cpp new file mode 100644 index 0000000000..8154a7954f --- /dev/null +++ b/tests/validation/gpu/unit/Queue.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2021 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation/fixtures/UNIT/QueueFixture.h" + +#include "arm_compute/AclOpenClExt.h" +#include "src/gpu/cl/ClQueue.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(UNIT) +TEST_SUITE(Queue) + +EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueueWithInvalidContext, CreateQueueWithInvalidContextFixture, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueuerWithInvalidOptions, CreateQueuerWithInvalidOptionsFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidQueue, DestroyInvalidQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(SimpleQueue, SimpleQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) + +TEST_CASE(KhrQueuePriorities, framework::DatasetMode::ALL) +{ + acl::StatusCode err = acl::StatusCode::Success; + + acl::Context ctx(acl::Target::GpuOcl, &err); + ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success); + + acl::Queue queue(ctx, &err); + ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success); + + cl_device_id cl_dev; + auto status = AclGetClDevice(ctx.get(), &cl_dev); + ARM_COMPUTE_ASSERT(status == AclSuccess); + + std::string extensions = cl::Device(cl_dev).getInfo<CL_DEVICE_EXTENSIONS>(); + if(extensions.find("cl_khr_priority_hints") != std::string::npos) + { + cl_int error = CL_SUCCESS; + + cl_context cl_ctx; + auto status = AclGetClContext(ctx.get(), &cl_ctx); + ARM_COMPUTE_ASSERT(status == AclSuccess); + + /* Check a queue with high priority */ + cl_queue_properties queue_properties[] = { CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0 }; + cl_command_queue priority_queue = clCreateCommandQueueWithProperties(cl_ctx, cl_dev, queue_properties, &error); + ARM_COMPUTE_ASSERT(error == CL_SUCCESS); + + clReleaseCommandQueue(priority_queue); + } +} + +TEST_SUITE_END() // Queue +TEST_SUITE_END() // UNIT +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/gpu/unit/Tensor.cpp b/tests/validation/gpu/unit/Tensor.cpp new file mode 100644 index 0000000000..18102733ce --- /dev/null +++ b/tests/validation/gpu/unit/Tensor.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation/fixtures/UNIT/TensorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(UNIT) +TEST_SUITE(Tensor) + +EMPTY_BODY_FIXTURE_TEST_CASE(CreateTensorWithInvalidContext, CreateTensorWithInvalidContextFixture, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(CreateTensorWithInvalidDescriptor, CreateTensorWithInvalidDescriptorFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidTensor, DestroyInvalidTensorFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(SimpleTensor, SimpleTensorFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(TensorStress, TensorStressFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(MapInvalidTensor, MapInvalidTensorFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(MapAllocatedTensor, MapAllocatedTensorFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(GetSize, TensorSizeFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(GetInvalidSize, InvalidTensorSizeFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(GetDescriptor, DescriptorConversionFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(GetInvalidDescriptor, InvalidDescriptorConversionFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) + +TEST_SUITE_END() // Tensor +TEST_SUITE_END() // UNIT +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/gpu/unit/TensorPack.cpp b/tests/validation/gpu/unit/TensorPack.cpp new file mode 100644 index 0000000000..b62426d056 --- /dev/null +++ b/tests/validation/gpu/unit/TensorPack.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation/fixtures/UNIT/TensorPackFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(UNIT) +TEST_SUITE(TensorPack) + +EMPTY_BODY_FIXTURE_TEST_CASE(CreateTensorPackWithInvalidContext, CreateTensorPackWithInvalidContextFixture, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidTensorPack, DestroyInvalidTensorPackFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(AddInvalidObjectToTensorPack, AddInvalidObjectToTensorPackFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(SimpleTensorPack, SimpleTensorPackFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) +EMPTY_BODY_FIXTURE_TEST_CASE(MultipleTensorsInPack, MultipleTensorsInPackFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL) + +TEST_SUITE_END() // Tensor +TEST_SUITE_END() // UNIT +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute |