Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test_plans/queue-shortcut-functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ The below functions are called to set some USM zero-initialized buffer `ptr` to
==== Prefetch
Each of the below functions is called with some USM buffer. It is checked whether the return type of the functions is `event`. The USM buffers are allocation type `shared`. If the used device lacks this capability (aspect `aspect::usm_shared_allocations`), this test is skipped.

* `event prefetch(void* ptr, size_t numBytes)`
* `event prefetch(void* ptr, size_t numBytes, event depEvent)`
* `event prefetch(void* ptr, size_t numBytes, const std::vector<event>& depEvents)`
* `event prefetch(const void* ptr, size_t numBytes)`
* `event prefetch(const void* ptr, size_t numBytes, event depEvent)`
* `event prefetch(const void* ptr, size_t numBytes, const std::vector<event>& depEvents)`

==== Memory advise
Each of the below functions is called with some USM buffer. It is checked whether the return type of the functions is `event`. The value of `advice` is `0`. The USM buffers are allocation type `device`. If the used device lacks this capability (aspect `aspect::usm_device_allocations`), this test is skipped.

* `event mem_advise(void* ptr, size_t numBytes, int advice)`
* `event mem_advise(void* ptr, size_t numBytes, int advice, event depEvent)`
* `event mem_advise(void* ptr, size_t numBytes, int advice, const std::vector<event>& depEvents)`
* `event mem_advise(const void* ptr, size_t numBytes, int advice)`
* `event mem_advise(const void* ptr, size_t numBytes, int advice, event depEvent)`
* `event mem_advise(const void* ptr, size_t numBytes, int advice, const std::vector<event>& depEvents)`

=== Explicit copy
All accessors used are one-dimensional.
Expand Down
30 changes: 22 additions & 8 deletions tests/queue/queue_shortcuts_usm.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ template <typename T>
void test_unified_shared_memory(sycl::queue q, unsigned int element_count) {
const bool has_usm_device_allocations =
q.get_device().has(sycl::aspect::usm_device_allocations);
const bool has_usm_shared_allocations =
q.get_device().has(sycl::aspect::usm_shared_allocations);

runner_memcpy<T> runner(q, element_count);

Expand Down Expand Up @@ -234,10 +232,16 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) {
"Device does not support USM device allocations. "
"Skipping the test case.");
}
}

template <typename T>
void test_prefetch(sycl::queue q, unsigned int element_count) {
const bool has_usm_shared_allocations =
q.get_device().has(sycl::aspect::usm_shared_allocations);

// prefetch
if (has_usm_shared_allocations) {
T* ptr = sycl::malloc_shared<T>(element_count, q);
const T* ptr =
static_cast<const T*>(sycl::malloc_shared<T>(element_count, q));
sycl::event prefetch_no_events = q.prefetch(ptr, element_count * sizeof(T));
sycl::event prefetch_single_event =
q.prefetch(ptr, element_count * sizeof(T), prefetch_no_events);
Expand All @@ -246,16 +250,22 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) {
{prefetch_no_events, prefetch_single_event});
prefetch_multiple_events.wait();
prefetch_no_events.wait();
sycl::free(ptr, q);
sycl::free(const_cast<T*>(ptr), q);
} else {
WARN(
"Device does not support USM shared allocations. "
"Skipping the test case.");
}
}

template <typename T>
void test_mem_advise(sycl::queue q, unsigned int element_count) {
const bool has_usm_device_allocations =
q.get_device().has(sycl::aspect::usm_device_allocations);

// advise
if (has_usm_device_allocations) {
T* ptr = sycl::malloc_device<T>(element_count, q);
const T* ptr =
static_cast<const T*>(sycl::malloc_device<T>(element_count, q));
constexpr int advice = 0;
sycl::event advise_no_events =
q.mem_advise(ptr, element_count * sizeof(T), advice);
Expand All @@ -266,7 +276,7 @@ void test_unified_shared_memory(sycl::queue q, unsigned int element_count) {
{advise_no_events, advise_single_event});
advise_multiple_events.wait();
advise_no_events.wait();
sycl::free(ptr, q);
sycl::free(const_cast<T*>(ptr), q);
} else {
WARN(
"Device does not support USM device allocations. "
Expand All @@ -283,6 +293,10 @@ class check_queue_shortcuts_usm_for_type {
INFO("for type \"" << type_name << "\": ");

test_unified_shared_memory<T>(queue, element_count);
#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
test_prefetch<T>(queue, element_count);
test_mem_advise<T>(queue, element_count);
#endif
}
};

Expand Down
4 changes: 2 additions & 2 deletions tests/usm/usm_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class prefetch : public detail::noAdditionalDeviceRequirements {
}

template <typename parentT, typename... depEventsT>
auto call(parentT &parent, T *ptr, depEventsT &&... events) const {
auto call(parentT& parent, const T* ptr, depEventsT&&... events) const {
return parent.prefetch(ptr, size, std::forward<depEventsT>(events)...);
}

Expand Down Expand Up @@ -444,7 +444,7 @@ class mem_advise : public detail::noAdditionalDeviceRequirements {
}

template <typename parentT, typename... depEventsT>
auto call(parentT &parent, T *ptr, depEventsT &&... events) const {
auto call(parentT& parent, const T* ptr, depEventsT&&... events) const {
const int advice = 0; // Reset to defaults according to the SYCL 2020 spec
return parent.mem_advise(ptr, size, advice,
std::forward<depEventsT>(events)...);
Expand Down
34 changes: 8 additions & 26 deletions tests/usm/usm_api_mem_advise_handler_no_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_mem_advise_handler_no_events

namespace TEST_NAMESPACE {
namespace usm_api_mem_advise_handler_no_events {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::mem_advise, caller::handler, 0_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_mem_advise_handler_no_events", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::mem_advise, caller::handler, 0_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_mem_advise_handler_no_events
34 changes: 8 additions & 26 deletions tests/usm/usm_api_mem_advise_queue_multiple_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_mem_advise_queue_multiple_events

namespace TEST_NAMESPACE {
namespace usm_api_mem_advise_queue_multiple_events {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::mem_advise, caller::queue, multiple_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_mem_advise_queue_multiple_events", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::mem_advise, caller::queue, multiple_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_mem_advise_queue_multiple_events
34 changes: 8 additions & 26 deletions tests/usm/usm_api_mem_advise_queue_no_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_mem_advise_queue_no_events

namespace TEST_NAMESPACE {
namespace usm_api_mem_advise_queue_no_events {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::mem_advise, caller::queue, 0_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_mem_advise_queue_no_events", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::mem_advise, caller::queue, 0_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_mem_advise_queue_no_events
34 changes: 8 additions & 26 deletions tests/usm/usm_api_mem_advise_queue_single_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_mem_advise_queue_single_event

namespace TEST_NAMESPACE {
namespace usm_api_mem_advise_queue_single_event {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::mem_advise, caller::queue, 1_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_mem_advise_queue_single_event", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::mem_advise, caller::queue, 1_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_mem_advise_queue_single_event
34 changes: 8 additions & 26 deletions tests/usm/usm_api_prefetch_handler_no_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_prefetch_handler_no_events

namespace TEST_NAMESPACE {
namespace usm_api_prefetch_handler_no_events {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::prefetch, caller::handler, 0_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_prefetch_handler_no_events", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::prefetch, caller::handler, 0_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_prefetch_handler_no_events
34 changes: 8 additions & 26 deletions tests/usm/usm_api_prefetch_queue_multiple_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@
*******************************************************************************/

#include "../common/common.h"
#include "../common/disabled_for_test_case.h"
#include "usm_api.h"

#define TEST_NAME usm_api_prefetch_queue_multiple_events

namespace TEST_NAMESPACE {
namespace usm_api_prefetch_queue_multiple_events {
using namespace usm_api;

template <typename T>
using run_tests = run_all_tests<T, tests::prefetch, caller::queue, multiple_events>;

/** Test instance
*/
class TEST_NAME : public sycl_cts::util::test_base {
public:
/** return information about this test
*/
void get_info(test_base::info &out) const override {
set_test_info(out, TOSTRING(TEST_NAME), TEST_FILE);
}

/** execute the test
*/
void run(sycl_cts::util::logger &log) override {
run_tests<int>{}(log);
}
};

// construction of this proxy will register the above test
sycl_cts::util::test_proxy<TEST_NAME> proxy;
DISABLED_FOR_TEST_CASE(SimSYCL)
("usm_api_prefetch_queue_multiple_events", "[usm]")({
sycl_cts::util::logger log;
run_all_tests<int, tests::prefetch, caller::queue, multiple_events>{}(log);
});

} // namespace TEST_NAMESPACE
} // namespace usm_api_prefetch_queue_multiple_events
Loading
Loading