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 8FBA5A04A3; Wed, 26 Jan 2022 20:40:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7E514275D; Wed, 26 Jan 2022 20:40:51 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2068.outbound.protection.outlook.com [40.107.100.68]) by mails.dpdk.org (Postfix) with ESMTP id C8F034275C for ; Wed, 26 Jan 2022 20:40:49 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gt3pbM+yLeqkSaOJN9GKmGJNGPopWQkC26cpr/n+KrztnvM+A8afCIczZhVIROYNbYwOi3EfSjxkK9SFzf2hXgfXaLITtHF7HEbFOpfYSFs5xiVRcsS808f2YykAQnRwnYAE7f01Djx97ODY9vhoCx0pPbt6s2gOimqTcuW0UBMmAay+T7ALyoFuzbxpGr9P3/9TvP5fdjoSD1z0MgKAEqUwApyD4d+3VJbB5fDQyUM94pmh2OGMVvCLLZ9FosnISnXn1SBH5Gry8wYJPE7czJ6jrl1rPLgKeUU9lrt3DOCcOUJr1kqAG9hU+zqpWf8yjef2Zemjq/TypgEP0nFzjg== 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=xOiLs/pfJin1CsOlUbjfSHdZj6BOOPyBCgQmg5q+SOI=; b=L4zoBB3qymuaByqzBmylW0bC7khZiztsCBJO3Z2fxB1h4xfNCNKWgfecdhnxa1goQkvac68ZTxgyfZT2/OuIj3rlUSQYs8Jp92pkQp8qBCYFkXs6GAe6njDRVMZTfgJD5kVPyGYA9kjO6SmizNiRy9+edvhpb6PtrdaBlTM2rRuHCLcSs3MeroTw6s5Gb1Qz9nYtSl6nYyVD8lN4DfAnz0M5ARt/Yv9+QJs+WqJ63F4krkNRaIgISBQzGjn0zVMMSGZRyLRW26R4fCNxWd0bLY+yFCVL5NQ96hNMwO6HrHIFkG7GB2obAnkEw8LjubKFvCh5v/Bi0pLxaynOYFqFBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=xOiLs/pfJin1CsOlUbjfSHdZj6BOOPyBCgQmg5q+SOI=; b=boqENzBV97CGQZxcc2TLu1ooL271inpRH7/fDgiX0+gC/oVwAQBrJwY6Y/xmxZIKRHZorH1Jm/cKlcc4i6GmgPPhTYaXDQQ0AIaKwjeSeZ7VP/ZWZ7rJr05Ckg9TsNBMir+qEcbHI1q381ZbJi7MyWTPUvYzY+ey3koMntVWjb7s40QhjzqhqF+sF3AhR2pkITBGMhrh3o7BqO6g8jU9hRQ0wlcQ5v2RW9wteFoBUWhUtppWP/1/Y8eH63/5ZqGFpOqL3L2ixFYr/tlU0h+q4mYVpnmYONafUBmBc2z5f5BiAG9XKyfnTNwgcNmABqrZ86zcnsp167vQ7c+3ZD1Kjw== Received: from MW4PR04CA0168.namprd04.prod.outlook.com (2603:10b6:303:85::23) by DM5PR12MB1387.namprd12.prod.outlook.com (2603:10b6:3:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Wed, 26 Jan 2022 19:40:47 +0000 Received: from CO1NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::42) by MW4PR04CA0168.outlook.office365.com (2603:10b6:303:85::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Wed, 26 Jan 2022 19:40:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT045.mail.protection.outlook.com (10.13.175.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Wed, 26 Jan 2022 19:40:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 26 Jan 2022 19:40:44 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Wed, 26 Jan 2022 11:40:44 -0800 From: To: CC: Elena Agostini Subject: [PATCH v5 2/2] app/test-gpudev: test cpu_map/cpu_unmap functions Date: Thu, 27 Jan 2022 03:50:29 +0000 Message-ID: <20220127035029.12920-2-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220127035029.12920-1-eagostini@nvidia.com> References: <20220104023408.13379-1-eagostini@nvidia.com> <20220127035029.12920-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: drhqmail202.nvidia.com (10.126.190.181) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 429723e8-6316-4d5c-d0a1-08d9e103c02c X-MS-TrafficTypeDiagnostic: DM5PR12MB1387:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 06qb4QTLrGEexvY32Pltu9T3bcoFo/huMFiZCMiK9cNeEalbyHTfGY1EP9PPL4Rlu2qkYvmjzRzU7oRh1NoxmIncwROhysC3yBh80/2fnjD4HDwSKv8A64d/IC/FCD7NEDo5yv+qTSutkb2S32fvRldMMgzZxFUFx9lcjktC81stC4wv7p1b+M8dIx953P6VEemFOyo9ZenbkAEken2VHHUMWgc20OJ5ODVxGhE1NShmJ2oZLZw0+XBcywVcIyk4ciTobV80qdGMS8ed07Yvyd+HdOF2L16FF1lxhG4i/Q+G8qTPxbz5djwxPJTJ2lyCC3DjTkvB2d5A6RI5UtxKULuF0pFBJJRYZsEAUpm5bPGDfcYsWLkmcl8I69CP3X6k6A9nvYnviIXPk5k81ReBCOOgwwsjdleKPJz5+uVYdDLTF+RiQfmBpUyHOUwhmJC5eUSkVyZegS3QERbcN4OkMGr2ECmYgu7cUb79yqIsznjPSvqu/Xb56gZleNTVQMaHME7QIlSH/ijJSJcy63J50U0S/A6wShP2qiRYKSHMvvgA2Ivu1anM91fqFs84Cf0tMXekiYdBWjA4OQ5mpN0FJGmOpFXDp/n5xXkXh5hNz2320o2tgqBmWhsNMERkuj0UVoDnQrFj5F81RMPYi/o66dqpppSCuBMF+WWBsU9OLdUgiD2BeRziQcPdtlSAG4xuqf3GuCdDcJ9N5Ep3iWuU2dQPbWHm2jk5BgqlSQlkB7r7LxSgnm8w39CQluYqD3JIfY+QJoJcqSm3KtJQ+SMlLKADDG1NC3B6nzgOiHgUReg= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(4636009)(40470700004)(36840700001)(46966006)(81166007)(8936002)(2906002)(356005)(426003)(26005)(8676002)(336012)(2616005)(6286002)(2876002)(316002)(508600001)(7696005)(55016003)(36860700001)(82310400004)(6916009)(5660300002)(40460700003)(86362001)(1076003)(36756003)(47076005)(16526019)(70586007)(4326008)(83380400001)(6666004)(70206006)(186003)(107886003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 19:40:47.3699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 429723e8-6316-4d5c-d0a1-08d9e103c02c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1387 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 New test case added to test the gpudev cpu_map/cpu_unmap functions. Signed-off-by: Elena Agostini --- app/test-gpudev/main.c | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c index 4500a8660b..417f2d78b7 100644 --- a/app/test-gpudev/main.c +++ b/app/test-gpudev/main.c @@ -185,6 +185,68 @@ register_cpu_memory(uint16_t gpu_id) return -1; } +static int +gpu_mem_cpu_map(uint16_t gpu_id) +{ + void *ptr_gpu = NULL; + void *ptr_cpu = NULL; + size_t buf_bytes = 1024; + unsigned int align = 4096; + int ret; + + printf("\n=======> TEST: Map GPU memory for CPU visibility\n\n"); + + /* Alloc memory on GPU 0 with 4kB alignment */ + ptr_gpu = rte_gpu_mem_alloc(gpu_id, buf_bytes, align); + if (ptr_gpu == NULL) { + fprintf(stderr, "rte_gpu_mem_alloc GPU memory returned error\n"); + goto error; + } + printf("GPU memory allocated at 0x%p size is %zd bytes\n", + ptr_gpu, buf_bytes); + + ptr_cpu = rte_gpu_mem_cpu_map(gpu_id, buf_bytes, ptr_gpu); + if (ptr_cpu == NULL) { + fprintf(stderr, "rte_gpu_mem_cpu_map returned error\n"); + goto error; + } + printf("GPU memory mapped for CPU access at 0x%p\n", ptr_cpu); + + ((uint8_t *)ptr_cpu)[0] = 0x4; + ((uint8_t *)ptr_cpu)[1] = 0x5; + ((uint8_t *)ptr_cpu)[2] = 0x6; + + printf("GPU memory first 3 bytes set from CPU: %x %x %x\n", + ((uint8_t *)ptr_cpu)[0], + ((uint8_t *)ptr_cpu)[1], + ((uint8_t *)ptr_cpu)[2]); + + ret = rte_gpu_mem_cpu_unmap(gpu_id, ptr_cpu); + if (ret < 0) { + fprintf(stderr, "rte_gpu_mem_cpu_unmap returned error %d\n", ret); + goto error; + } + printf("GPU memory mapped for CPU access at 0x%p\n", ptr_cpu); + + ret = rte_gpu_mem_free(gpu_id, ptr_gpu); + if (ret < 0) { + fprintf(stderr, "rte_gpu_mem_free returned error %d\n", ret); + goto error; + } + printf("GPU memory 0x%p freed\n", ptr_gpu); + + printf("\n=======> TEST: PASSED\n"); + return 0; + +error: + + rte_gpu_mem_cpu_unmap(gpu_id, ptr_cpu); + rte_gpu_mem_free(gpu_id, ptr_gpu); + + printf("\n=======> TEST: FAILED\n"); + return -1; +} + static int create_update_comm_flag(uint16_t gpu_id) { @@ -402,6 +464,7 @@ main(int argc, char **argv) */ alloc_gpu_memory(gpu_id); register_cpu_memory(gpu_id); + gpu_mem_cpu_map(gpu_id); /** * Communication items test -- 2.17.1