-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathPageRequester.cu
More file actions
33 lines (26 loc) · 1.34 KB
/
Copy pathPageRequester.cu
File metadata and controls
33 lines (26 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
#include <OptiXToolkit/DemandLoading/Paging.h>
#include "Simple.h"
using namespace demandLoading;
__global__ static void pageRequester( DeviceContext context, unsigned int pageBegin, unsigned int pageEnd, PageTableEntry* pageTableEntries )
{
unsigned int numPages = pageEnd - pageBegin;
unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
if( index >= numPages )
return;
unsigned int pageId = pageBegin + index;
bool isResident;
unsigned long long entry = pagingMapOrRequest( context, pageId, &isResident );
if( isResident )
pageTableEntries[index] = entry;
}
__host__ void launchPageRequester( cudaStream_t stream, const DeviceContext& context, unsigned int pageBegin, unsigned int pageEnd, PageTableEntry* pageTableEntries )
{
unsigned int threadsPerBlock = 32;
unsigned int numPages = pageEnd - pageBegin;
unsigned int numBlocks = ( numPages + threadsPerBlock - 1 ) / threadsPerBlock;
// The DeviceContext is passed by value to the kernel, so it is copied to device memory when the kernel is launched.
pageRequester<<<numBlocks, threadsPerBlock, 0U, stream>>>( context, pageBegin, pageEnd, pageTableEntries );
}