From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF095A0032; Mon, 15 Nov 2021 15:53:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D78A540E01; Mon, 15 Nov 2021 15:53:26 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) by mails.dpdk.org (Postfix) with ESMTP id A615B40141 for ; Mon, 15 Nov 2021 15:53:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcmkAmCJzUfm9t7VqY8ol+2gDJjzDbS9i3DWtbsD4qef2hxP/UybQmNIF58WXQqKtFj830EzhoPB68GlMTf/WnpIDSCh467c1I6ktLUFibMaxXiuIQjgagPNw1fQZBnhsKV5dhfVW/TrwftS4Yg/8+pY5vkSPlcKGp667531Uz0s67I+WBGy8F1CdDuCNmTQDcrzv7KleU760Blv9FfRmT/BiXb90gnVif0HtV+Qq/kHuMU1/LzN1nfOP8ZDWlWHiIfjw/XUlB4S8z+4+Ljie72H4l7S9cSW9SlUVBibqkBIqG1w/4kJr1Q/0JPPRRW+Mtm+nxuewiUie7XiQqsHVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VP+CK/NVE1F0UGA3Zhet4jGCQER5XL8/GSxEfJNHf9k=; b=Ly/3h2KSUoa0yAVaJmNUTn2j8MB54r7aMh6giMSb5F2Fjx3Go2zQHfQXbs8hFry7uTmYTFSAEBuZahWH7VUltSnp3AOZa51TDC3TRwwzb8CDjHn3CsP2PMszTk35LeKQR0iiJYCDPrN1/IMnqj7gr8z6k9Jvp+2CtgUk6zRfHRb5QERpZhDK6yzJU1Sb2vh0yDfA2Ivn2DXTndD2efanI0P3JIAZtIgzYuCcsOHiNF6xvCmUUH0Lxm9SG/oONdiQvMo9xVf5iGreV5QIX7qloXP4ic9FS8c/5Svzr01m5+bFuFLiQNfnzGpF4kb96soL3YT/achrzwB/BFKfJb09Hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VP+CK/NVE1F0UGA3Zhet4jGCQER5XL8/GSxEfJNHf9k=; b=R5kcM4NWp31A7yNy5Y/vsOqmolm7I3CyC0OCZAAaEe1oBxwEGNIFwbEp0+cFGmcgS2ec0rQOdEcfBQ5Epg55SaWcZgWPU042qlLiA+qO4AiQFwb4Cax7MMHFFVOFWHIAnz1jSdxxWMzOUYGTnSU2hiZPQ4rn0aB76AbGrGpnJ/IIscB3v4C6NJ0plV/MyUQO9eVbgbLmMbeevtmOaYMKH2UBgDnk06E0WB2mzb5fARkaP8VSPs7hcWMIHNxOXY95YRtirke6c3tn2NM1Bm0LuD7l5cbBlOgs0BM28oztNG92o/CicR3UNarrt6mRZxWS6cS44xHjlpy69P77HWMKOQ== Received: from DS7PR03CA0099.namprd03.prod.outlook.com (2603:10b6:5:3b7::14) by CH0PR12MB5169.namprd12.prod.outlook.com (2603:10b6:610:b8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.17; Mon, 15 Nov 2021 14:53:23 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::16) by DS7PR03CA0099.outlook.office365.com (2603:10b6:5:3b7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Mon, 15 Nov 2021 14:53:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Mon, 15 Nov 2021 14:53:23 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 15 Nov 2021 14:53:06 +0000 From: To: CC: Elena Agostini Subject: [PATCH v1] app/test-gpudev: improve tests' output Date: Mon, 15 Nov 2021 23:03:28 +0000 Message-ID: <20211115230328.20618-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3e4a311-6622-4630-21c8-08d9a847ac10 X-MS-TrafficTypeDiagnostic: CH0PR12MB5169: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:254; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aHPxcU7cM4tZcLxjYMvm5cTPITQrXA6rqjxlhfA09wm8NFtZ67tnfMLzr8/AqqObgE02yEMwZ+097UlMM0sJ/puzt7HPYVThEzQpl82kprkQ/s/VliC+H/HUE+RxUksKjv7imQX0c/QarUs40mpgZ5N8TD2ehfVPWO2p80dZg4nqk9JIrzlUCxoT1p9iDsg3qBtgij6vuriVWdHRQuUFAgWBzKELlz0hz009I+NELYMcapIVMchJTxcS6I07Z4sb6C6fQ6L4vnbDaa8ThzvUZcAE+SqCvvvUiAITx6np7aAi/AG+Yf2hke0pA298XlTcAMt6V0J+DEnqksC12HEq/i/whi8inV5ntOYbuc6fmHi/CruAsxNYcQYdVb4BJYggWvsJsvXsx044+eSzBEIm60IdHJMEpqLfHAfaqDu6YSFgutEAYoadn3AJTrAhnH465IEw2NZAvy3HMb0NseJ9WFP1CDOw84L4UyvIJbK7xEZioMnDgH+6TakGk5zMPV0Z91eAwWN9UVckjkjOyjyMx4aB2D6PknZkhDTEFd6Sgu8e7DMVK4UU8I9qzXcxbgPpE0CHy/HyEms87VIg98DImYHGuQiFmakt9rodaUCzDxjplvQrrurxE/G5O871r2RSUxDmVZ7ojt0XhQLRM4+XDojYpx+M7aZapN5/4sLul5wOKkL8VJciAh++MwZlFR00NIt2hj1CKKdr2bQCXowh8g== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(55016002)(316002)(70586007)(2876002)(82310400003)(7696005)(70206006)(6666004)(6916009)(26005)(5660300002)(186003)(16526019)(7636003)(1076003)(8936002)(47076005)(6286002)(356005)(36756003)(83380400001)(36860700001)(36906005)(2906002)(107886003)(86362001)(4326008)(2616005)(508600001)(336012)(8676002)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2021 14:53:23.1259 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3e4a311-6622-4630-21c8-08d9a847ac10 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5169 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Elena Agostini Signed-off-by: Elena Agostini --- app/test-gpudev/main.c | 90 ++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c index 1db3f69e10..e42133b3aa 100644 --- a/app/test-gpudev/main.c +++ b/app/test-gpudev/main.c @@ -70,46 +70,51 @@ alloc_gpu_memory(uint16_t gpu_id) size_t buf_bytes = 1024; int ret; - printf("\n=======> TEST: Allocate GPU memory\n"); + printf("\n=======> TEST: Allocate GPU memory\n\n"); /* Alloc memory on GPU 0 */ ptr_1 = rte_gpu_mem_alloc(gpu_id, buf_bytes); if (ptr_1 == NULL) { fprintf(stderr, "rte_gpu_mem_alloc GPU memory returned error\n"); - return -1; + goto error; } - printf("GPU memory allocated at 0x%p %zdB\n", ptr_1, buf_bytes); + printf("GPU memory allocated at 0x%p size is %zd bytes\n", ptr_1, buf_bytes); ptr_2 = rte_gpu_mem_alloc(gpu_id, buf_bytes); if (ptr_2 == NULL) { fprintf(stderr, "rte_gpu_mem_alloc GPU memory returned error\n"); - return -1; + goto error; } - printf("GPU memory allocated at 0x%p %zdB\n", ptr_2, buf_bytes); + printf("GPU memory allocated at 0x%p size is %zd bytes\n", ptr_2, buf_bytes); ret = rte_gpu_mem_free(gpu_id, (uint8_t *)(ptr_1)+0x700); if (ret < 0) { - printf("GPU memory 0x%p + 0x700 NOT freed because of memory address not recognized by driver\n", ptr_1); + printf("GPU memory 0x%p NOT freed: gpu driver didn't find this memory address internally.\n", (uint8_t *)(ptr_1)+0x700); } else { - fprintf(stderr, "rte_gpu_mem_free erroneously freed GPU memory 0x%p + 0x700\n", ptr_1); - return -1; + fprintf(stderr, "ERROR: rte_gpu_mem_free freed GPU memory 0x%p\n", (uint8_t *)(ptr_1)+0x700); + goto error; } ret = rte_gpu_mem_free(gpu_id, ptr_2); if (ret < 0) { fprintf(stderr, "rte_gpu_mem_free returned error %d\n", ret); - return -1; + goto error; } printf("GPU memory 0x%p freed\n", ptr_2); ret = rte_gpu_mem_free(gpu_id, ptr_1); if (ret < 0) { fprintf(stderr, "rte_gpu_mem_free returned error %d\n", ret); - return -1; + goto error; } printf("GPU memory 0x%p freed\n", ptr_1); + printf("\n=======> TEST: PASSED\n"); return 0; + +error: + printf("\n=======> TEST: FAILED\n"); + return -1; } static int @@ -119,39 +124,43 @@ register_cpu_memory(uint16_t gpu_id) size_t buf_bytes = 1024; int ret; - printf("\n=======> TEST: Register CPU memory\n"); + printf("\n=======> TEST: Register CPU memory\n\n"); /* Alloc memory on CPU visible from GPU 0 */ ptr = rte_zmalloc(NULL, buf_bytes, 0); if (ptr == NULL) { fprintf(stderr, "Failed to allocate CPU memory.\n"); - return -1; + goto error; } ret = rte_gpu_mem_register(gpu_id, buf_bytes, ptr); if (ret < 0) { fprintf(stderr, "rte_gpu_mem_register CPU memory returned error %d\n", ret); - return -1; + goto error; } printf("CPU memory registered at 0x%p %zdB\n", ptr, buf_bytes); ret = rte_gpu_mem_unregister(gpu_id, (uint8_t *)(ptr)+0x700); if (ret < 0) { - printf("CPU memory 0x%p + 0x700 NOT unregistered because of memory address not recognized by driver\n", ptr); + printf("CPU memory 0x%p NOT unregistered: gpu driver didn't find this memory address internally\n", (uint8_t *)(ptr)+0x700); } else { - fprintf(stderr, "rte_gpu_mem_free erroneously freed GPU memory 0x%p + 0x700\n", ptr); - return -1; + fprintf(stderr, "ERROR: rte_gpu_mem_unregister unregistered GPU memory 0x%p\n", (uint8_t *)(ptr)+0x700); + goto error; } - printf("CPU memory 0x%p unregistered\n", ptr); ret = rte_gpu_mem_unregister(gpu_id, ptr); if (ret < 0) { fprintf(stderr, "rte_gpu_mem_unregister returned error %d\n", ret); - return -1; + goto error; } printf("CPU memory 0x%p unregistered\n", ptr); + printf("\n=======> TEST: PASSED\n"); return 0; + +error: + printf("\n=======> TEST: FAILED\n"); + return -1; } static int @@ -162,25 +171,25 @@ create_update_comm_flag(uint16_t gpu_id) uint32_t set_val; uint32_t get_val; - printf("\n=======> TEST: Communication flag\n"); + printf("\n=======> TEST: Communication flag\n\n"); ret = rte_gpu_comm_create_flag(gpu_id, &devflag, RTE_GPU_COMM_FLAG_CPU); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_create_flag returned error %d\n", ret); - return -1; + goto error; } set_val = 25; ret = rte_gpu_comm_set_flag(&devflag, set_val); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_set_flag returned error %d\n", ret); - return -1; + goto error; } ret = rte_gpu_comm_get_flag_value(&devflag, &get_val); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_get_flag_value returned error %d\n", ret); - return -1; + goto error; } printf("Communication flag value at 0x%p was set to %d and current value is %d\n", devflag.ptr, set_val, get_val); @@ -189,13 +198,13 @@ create_update_comm_flag(uint16_t gpu_id) ret = rte_gpu_comm_set_flag(&devflag, set_val); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_set_flag returned error %d\n", ret); - return -1; + goto error; } ret = rte_gpu_comm_get_flag_value(&devflag, &get_val); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_get_flag_value returned error %d\n", ret); - return -1; + goto error; } printf("Communication flag value at 0x%p was set to %d and current value is %d\n", devflag.ptr, set_val, get_val); @@ -203,10 +212,15 @@ create_update_comm_flag(uint16_t gpu_id) ret = rte_gpu_comm_destroy_flag(&devflag); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_destroy_flags returned error %d\n", ret); - return -1; + goto error; } + printf("\n=======> TEST: PASSED\n"); return 0; + +error: + printf("\n=======> TEST: FAILED\n"); + return -1; } static int @@ -236,12 +250,12 @@ create_update_comm_list(uint16_t gpu_id) uint32_t num_comm_items = 1024; struct rte_mbuf *mbufs[10]; - printf("\n=======> TEST: Communication list\n"); + printf("\n=======> TEST: Communication list\n\n"); comm_list = rte_gpu_comm_create_list(gpu_id, num_comm_items); if (comm_list == NULL) { fprintf(stderr, "rte_gpu_comm_create_list returned error %d\n", ret); - return -1; + goto error; } /** @@ -251,7 +265,7 @@ create_update_comm_list(uint16_t gpu_id) mbufs[i] = rte_zmalloc(NULL, sizeof(struct rte_mbuf), 0); if (mbufs[i] == NULL) { fprintf(stderr, "Failed to allocate fake mbufs in CPU memory.\n"); - return -1; + goto error; } memset(mbufs[i], 0, sizeof(struct rte_mbuf)); @@ -263,20 +277,21 @@ create_update_comm_list(uint16_t gpu_id) ret = rte_gpu_comm_populate_list_pkts(&(comm_list[0]), mbufs, 10); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_populate_list_pkts returned error %d\n", ret); - return -1; + goto error; } ret = rte_gpu_comm_cleanup_list(&(comm_list[0])); if (ret == 0) { fprintf(stderr, "rte_gpu_comm_cleanup_list erroneously cleaned the list even if packets have not been consumed yet\n"); - return -1; + goto error; } - fprintf(stderr, "rte_gpu_comm_cleanup_list correctly didn't clean up the packets because they have not been consumed yet\n"); + printf("Communication list not cleaned because packets have not been consumed yet.\n"); /** * Simulate a GPU tasks going through the packet list to consume * mbufs packets and release them */ + printf("Consuming packets...\n"); simulate_gpu_task(&(comm_list[0]), 10); /** @@ -286,20 +301,26 @@ create_update_comm_list(uint16_t gpu_id) ret = rte_gpu_comm_cleanup_list(&(comm_list[0])); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_cleanup_list returned error %d\n", ret); - return -1; + goto error; } + printf("Communication list cleaned because packets have been consumed now.\n"); + ret = rte_gpu_comm_destroy_list(comm_list, num_comm_items); if (ret < 0) { fprintf(stderr, "rte_gpu_comm_destroy_list returned error %d\n", ret); - return -1; + goto error; } for (i = 0; i < 10; i++) rte_free(mbufs[i]); - printf("\nCommunication list test passed!\n"); + printf("\n=======> TEST: PASSED\n"); return 0; + +error: + printf("\n=======> TEST: FAILED\n"); + return -1; } int @@ -360,7 +381,6 @@ main(int argc, char **argv) /* clean up the EAL */ rte_eal_cleanup(); - printf("Bye...\n"); return EXIT_SUCCESS; } -- 2.17.1