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 835D9A04A3; Wed, 26 Jan 2022 20:38:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81DB242759; Wed, 26 Jan 2022 20:38:08 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by mails.dpdk.org (Postfix) with ESMTP id 90A5E4274B for ; Wed, 26 Jan 2022 20:38:04 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OHuPpbiee3JO4tYYro026vd5VwmTu7M+uD1ecd//bIw4vGsnhNTQC1BOmopLmXsqOzi5sAYzSAEBCOyKfOTM12wJqcmk+XylD3XmnsY0+hX1+j37UUvk78QKozgscBIo9l0Qqvz/LA3TmWbUFVtEqqOkcvEfhUcbtNo8l2LxsdCj5RxpyX84/lur5GxmjY6cxlqxp1G7ASCsGk+yYbEu0iKNtvL2mbTLUtmsk3WArAQc/a7Fn7qGrXvVeLpD+QN3gZlVo7Q5qAYkLzAWFJ4oGYndzij5CADtmct8dOJKXR0mYX388k9RmbX9eq/3SREWSE07zVDt1t0XlC+Oq2lJ0Q== 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=jgFkEsnPmwdTi6jN8hQIKhpHMH+1/2wsaKtt3N9yXv0=; b=PK8nFjY9z0BjmR+ym2r7Rh7PD3u8aHYU86KejVpmsQ8dnLXYmENl2vH5uJUbRqZBmn/bON0Dp3Y63icSsl4GSlRch0+6eFOXlcHf9bw/UYgYDyPBMoeNNa1+V1mmo2RrD01ti3O5AXe8PqT59QwoeA6pDjrWcFIWXcK+mlCNDfiR2wcOToRH5T5Yt1j4kSSXMKZwBofLYWpwiqUZUrO5iHd+IdGk5mcgiKQKsA/WR3+93ujUSmsEC2dl8ko4JZvw5/WVldro58xJXsdJcnOuH2I+LHojmdXLRjSfI/v/auO5L9mBXl+fK7ylQBtpX+bkI37R1tEjVSsTV4kQJ+rsVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=jgFkEsnPmwdTi6jN8hQIKhpHMH+1/2wsaKtt3N9yXv0=; b=Jn237umRFiyoR897HhzVauvOPGU6qqYLGjQMdgKa+mZyNfHcXFlU4ojnHwbeJhFdD0js/3qABjIKlIeDDjBvyQ5tMFaVnlNdTdeq0pRxZwwfeudBsAWatvwjJ+m9Xc0Fe3JAcDZUDqn+5w+p3bPeL5sk2rIPwZ7B1hEb5LzD71gVoT5DmDd3YYHsdXOQ6htc1vPAf5ERiQ8nwLlA5xdnhK6W6uMRVsCjOYewxlb+3UYHWU60YRoL7yGqq0Md/l04d2Yz1oCD0tOy9/Z1lL+PzEkEXUZarc8kwR06S/9ZsEwCXHkEjFC1JSXSHu2M2MSHboj2UCCCIoKwRTJv2rZgtg== Received: from BN9PR03CA0949.namprd03.prod.outlook.com (2603:10b6:408:108::24) by BYAPR12MB3381.namprd12.prod.outlook.com (2603:10b6:a03:df::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Wed, 26 Jan 2022 19:38:02 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::86) by BN9PR03CA0949.outlook.office365.com (2603:10b6:408:108::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Wed, 26 Jan 2022 19:38:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) 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:38:02 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 26 Jan 2022 19:37:52 +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:37:52 -0800 From: To: CC: Elena Agostini Subject: [PATCH v4 2/2] app/test-gpudev: test cpu_map/cpu_unmap functions Date: Thu, 27 Jan 2022 03:47:16 +0000 Message-ID: <20220127034716.12497-2-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220127034716.12497-1-eagostini@nvidia.com> References: <20220104023408.13379-1-eagostini@nvidia.com> <20220127034716.12497-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: 4b6b4937-fcf1-4059-bd14-08d9e1035dd6 X-MS-TrafficTypeDiagnostic: BYAPR12MB3381: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: wCmI9Ybvtb4LHfF2MLNAsWq5Ta2FOmbFfY63rQlhK1gqRzrgNzXgLhKcLRDxikl7vIElsaA6+TB92bVxueQT46AvQFS+EO/hwXZ/4vJNjkA2VM2vN9rDg7G89TeKeUCxHTPgNl+Pce1OfO7jbwJYSHGZIaQjZRD2Bg1/R00vg6Az/Buzc2d6g+zOFk4ZYHdfs1/GXGhA+qu+300YQzSO9Q70+RXRcS84QDj4UgU6xsaemcp2mABGOTo5bDaN5zh6Z7+7gCC0pYOYv2M3+hanIfOIPlPCirIyxyyIsXBymdzj40ZnDEwRaIPBGyFgWjFVoza6qBMsBXCPKDZ1pWmQph/jQ0OB70UwlROjLi+W/KVgXccAEHGrSAWJkPAIx9nC1RPSChFzPA/MVOy0G1UJDXxcNbHbxwV72DIgHh4Suuli1BTx0Z9IcmguzwoBJnlERz4Epahl9bdygTH7QU8hZCRJDpj+P3PZ0EXCBNF9w4w2yskHhEmYptvLvqZjxWk7TBn7fxYNGkkBpYW5RUit5N1H3pnI0zyjOFQpBy8FaJ7dcc1ptLcZAhlQc/bmJqCPdC3gtjqtYx5fIdkrqP9l0+V3YBrMxzRjjpdXEHvhG718laWAYkNs/ik2pCw7RlO8c5i2coHu5WTMc9+mtrfKgiFbT8CS0+8ARQ5F3M35GoTC6J43ci0SXW/b0kbQi71/a8cRWyvuEYto7atIbNuUng== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(336012)(36860700001)(16526019)(2616005)(1076003)(186003)(426003)(107886003)(6286002)(2876002)(2906002)(356005)(70586007)(36756003)(4326008)(8676002)(70206006)(5660300002)(55016003)(8936002)(26005)(508600001)(86362001)(82310400004)(47076005)(7696005)(6666004)(316002)(81166007)(40460700003)(83380400001)(6916009)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 19:38:02.3266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b6b4937-fcf1-4059-bd14-08d9e1035dd6 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3381 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..3d0c17d8fd 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