[libdrm,2/3] amdgpu: A new option to choose which device to run most tests

Submitted by Xie, AlexBin on Jan. 19, 2017, 10:53 p.m.

Details

Message ID 1484866391-17175-2-git-send-email-AlexBin.Xie@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Xie, AlexBin Jan. 19, 2017, 10:53 p.m.
This can be used to test multiple GPUs

Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
---
 tests/amdgpu/amdgpu_test.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index e42ef9d..2437db4 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -108,12 +108,14 @@  static void display_test_suites(void)
 
 
 /** Help string for command line parameters */
-static const char usage[] = "Usage: %s [-hl] [<-s <suite id>> [-t <test id>]]\n"
-				"where:\n"
-				"       l - Display all suites and their tests\n"
-				"       h - Display this help\n";
+static const char usage[] =
+	"Usage: %s [-hl] [<-s <suite id>> [-t <test id>]] [-d <device_id>]\n"
+	"where:\n"
+	"       l - Display all suites and their tests\n"
+	"       d - Choose which device to run tests\n"
+	"       h - Display this help\n";
 /** Specified options strings for getopt */
-static const char options[]   = "hls:t:";
+static const char options[]   = "hls:t:d:";
 
 /* Open AMD devices.
  * Return the number of AMD device openned.
@@ -238,6 +240,7 @@  int main(int argc, char **argv)
 	int i = 0;
 	int suite_id = -1;	/* By default run everything */
 	int test_id  = -1;	/* By default run all tests in the suite */
+	int device_id = 0;	/* By default run most tests on device 0 */
 	CU_pSuite pSuite = NULL;
 	CU_pTest  pTest  = NULL;
 
@@ -266,6 +269,9 @@  int main(int argc, char **argv)
 		case 't':
 			test_id = atoi(optarg);
 			break;
+		case 'd':
+			device_id = atoi(optarg);
+			break;
 		case '?':
 		case 'h':
 			fprintf(stderr, usage, argv[0]);
@@ -283,6 +289,15 @@  int main(int argc, char **argv)
 		exit(EXIT_FAILURE);
 	}
 
+	if (device_id) {
+		/* Most tests run on device 0.
+		 * Swap the chosen device to device 0.
+		 */
+		i = drm_amdgpu[0];
+		drm_amdgpu[0] = drm_amdgpu[device_id];
+		drm_amdgpu[device_id] = i;
+	}
+
 	amdgpu_print_devices();
 
 	/* Initialize test suites to run */

Comments

On 19 January 2017 at 22:53, Alex Xie <AlexBin.Xie@amd.com> wrote:
> This can be used to test multiple GPUs
>
> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
> ---
>  tests/amdgpu/amdgpu_test.c | 25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
> index e42ef9d..2437db4 100644
> --- a/tests/amdgpu/amdgpu_test.c
> +++ b/tests/amdgpu/amdgpu_test.c
> @@ -108,12 +108,14 @@ static void display_test_suites(void)
>
>
>  /** Help string for command line parameters */
> -static const char usage[] = "Usage: %s [-hl] [<-s <suite id>> [-t <test id>]]\n"
> -                               "where:\n"
> -                               "       l - Display all suites and their tests\n"
> -                               "       h - Display this help\n";
> +static const char usage[] =
> +       "Usage: %s [-hl] [<-s <suite id>> [-t <test id>]] [-d <device_id>]\n"
> +       "where:\n"
> +       "       l - Display all suites and their tests\n"
> +       "       d - Choose which device to run tests\n"
You want to elaborate on what you mean with "device" here.
Even if currently "card0 is my Kabini, card1 Hawaii, card2 other" that
may change upon reboot.
So although very nice to say "0,1, 2..." things are non-deterministic.

-Emil
HI Emil,


See below.


Thanks,

Alex
On 20 January 2017 at 22:08, Xie, AlexBin <AlexBin.Xie@amd.com> wrote:
> HI Emil,
>
>
> See below.
>
>
> Thanks,
>
> Alex
>
>
>
> ________________________________
> From: Emil Velikov <emil.l.velikov@gmail.com>
> Sent: Friday, January 20, 2017 8:24 AM
> To: Xie, AlexBin
> Cc: amd-gfx mailing list
> Subject: Re: [PATCH libdrm 2/3] amdgpu: A new option to choose which device
> to run most tests
>
> On 19 January 2017 at 22:53, Alex Xie <AlexBin.Xie@amd.com> wrote:
>> This can be used to test multiple GPUs
>>
>> Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
>> ---
>>  tests/amdgpu/amdgpu_test.c | 25 ++++++++++++++++++++-----
>>  1 file changed, 20 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
>> index e42ef9d..2437db4 100644
>> --- a/tests/amdgpu/amdgpu_test.c
>> +++ b/tests/amdgpu/amdgpu_test.c
>> @@ -108,12 +108,14 @@ static void display_test_suites(void)
>>
>>
>>  /** Help string for command line parameters */
>> -static const char usage[] = "Usage: %s [-hl] [<-s <suite id>> [-t <test
>> id>]]\n"
>> -                               "where:\n"
>> -                               "       l - Display all suites and their
>> tests\n"
>> -                               "       h - Display this help\n";
>> +static const char usage[] =
>> +       "Usage: %s [-hl] [<-s <suite id>> [-t <test id>]] [-d
>> <device_id>]\n"
>> +       "where:\n"
>> +       "       l - Display all suites and their tests\n"
>> +       "       d - Choose which device to run tests\n"
> You want to elaborate on what you mean with "device" here.
> Even if currently "card0 is my Kabini, card1 Hawaii, card2 other" that
> may change upon reboot.
> So although very nice to say "0,1, 2..." things are non-deterministic.
>
> [Alex Bin Xie] Originally I just want to give a simple solution for people
> to swap to test another GPU device.
> Every time amdgpu_test runs, it lists the device id and its information. I
> was thinking to improve this but such as adding an option to list the
> devices. So that the 0, 1 ,2 does not change if computer is not reboot. If
> 0, 1, 2 is not deterministic, I have to give up this human friendly
> interface...
>
> How about choose the test device by bus ID?  I will add an option to list
> the devices with BUS ID (if people run drmdevice program, they know the
> information too). Then people can choose  device on which BUS ID to run the
> test. I will provide a new patch if there is no object to this.
>
Using BUS ID will a lot better and more robust.

Thanks again for sorting these out !
Emil