summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQiang Yu <Qiang.Yu@amd.com>2017-05-16 14:37:34 +0800
committerQiang Yu <Qiang.Yu@amd.com>2017-05-17 10:24:19 +0800
commita126c245306ba47190e60007bc1c41602b9c6e61 (patch)
treef320e7e1ab9158582433cefb98f2ae8fa5737887
parentfc110c512465e3532765c924326bd9b2961603bf (diff)
tests/amdgpu: Add test for multi GPUs SVM test v4
1. We try to open all GPUs when test starts. 2. Test multi GPUs for SVM v2: 1. Adjust title 2. Use drmGetDevices to get the number of cards available. 3. Add warning output option and facility into this unit test app. 4. Adjust a comment and delete useless C statement when open function call fails. 5. Add two informative outputs in single SVM test. v3: 1. Use general device name from drmGetDevices instead of fixed name. 2. open devices in a single "for" statement. 3. Create a function to close all devices. v4: [Qiang Yu] drop open all devices and amdgpu_printf changes [Jammy Zhou] 2f8e2d2e4a406bc290986eac600f4263259b5ac5 amdgpu_multi_svm_test part Signed-off-by: Alex Xie <AlexBin.Xie@amd.com> Acked-by: Christian K├Ânig <christian.koenig@amd.com> Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Change-Id: I481155784e7ebcfda3bfc7e68932a33d01d6843a
-rw-r--r--tests/amdgpu/basic_tests.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index b10aeb0d..7dfc0e2b 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -50,6 +50,7 @@ static void amdgpu_command_submission_sdma(void);
static void amdgpu_userptr_test(void);
static void amdgpu_semaphore_test(void);
static void amdgpu_svm_test(void);
+static void amdgpu_multi_svm_test(void);
static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -65,6 +66,7 @@ CU_TestInfo basic_tests[] = {
{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
{ "SW semaphore Test", amdgpu_semaphore_test },
{ "SVM Test", amdgpu_svm_test },
+ { "SVM Test (multi-GPUs)", amdgpu_multi_svm_test },
CU_TEST_INFO_NULL,
};
#define BUFFER_SIZE (8 * 1024)
@@ -1383,3 +1385,71 @@ static void amdgpu_svm_test(void)
amdgpu_svm_deinit(device_handle);
}
+
+static void amdgpu_multi_svm_test(void)
+{
+ int r;
+ int i;
+ uint64_t svm_mcs[MAX_CARDS_SUPPORTED];
+ amdgpu_va_handle va_handles[MAX_CARDS_SUPPORTED];
+ amdgpu_device_handle device_handles[MAX_CARDS_SUPPORTED];
+ uint32_t major_version;
+ uint32_t minor_version;
+
+ device_handles[0] = device_handle;
+
+ r = amdgpu_svm_init(device_handles[0]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ for (i = 1; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ r = amdgpu_device_initialize(drm_amdgpu[i], &major_version,
+ &minor_version, &device_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_svm_init(device_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+
+ printf("\n");
+ printf(" Testing to alloc and free SVM in all GPUs.\n");
+ printf(" The svm_mcs generally are same.\n");
+ for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ r = amdgpu_va_range_alloc(device_handles[i],
+ amdgpu_gpu_va_range_svm,
+ 0x1000000, 1, 0, &svm_mcs[i],
+ &va_handles[i], 0);
+ CU_ASSERT_EQUAL(r, 0);
+ printf(" card %d, svm_mc 0x%llx\n", i, svm_mcs[i]);
+ if (svm_mcs[i] != svm_mcs[0])
+ printf("WARNING: The SVM from different GPUs should be "
+ "able to be allocated from same location.");
+ r = amdgpu_va_range_free(va_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+
+ printf(" Testing to alloc SVM in all GPUs.\n");
+ printf(" The svm_mcs are generally different by 0x1000000\n");
+ for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ r = amdgpu_va_range_alloc(device_handles[i],
+ amdgpu_gpu_va_range_svm,
+ 0x1000000, 1, 0, &svm_mcs[i],
+ &va_handles[i], 0);
+ CU_ASSERT_EQUAL(r, 0);
+ printf(" card %d, svm_mc 0x%llx\n", i, svm_mcs[i]);
+ if (svm_mcs[i] - svm_mcs[0] != 0x1000000 * i)
+ printf("WARNING: The SVM from GPUs should be allocated sequentially.");
+ }
+
+ for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ r = amdgpu_va_range_free(va_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+
+ for (i = 1; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ amdgpu_svm_deinit(device_handles[i]);
+ r = amdgpu_device_deinitialize(device_handles[i]);
+ CU_ASSERT_EQUAL(r, 0);
+ }
+
+ amdgpu_svm_deinit(device_handles[0]);
+}