quic envsim: radiative heat transfer in vegetative and...

31
QUIC EnvSim: Radiative Heat Transfer in Vegetative and Urban Environments with NVIDIA OptiX Matthew Overby 1 Scot Halverson 2 , Brian Bailey 3 , Pete Willemsen 1 , Rob Stoll 3 , Eric Pardyjak 3 1 Department of Computer Science University of Minnesota Duluth, Duluth, MN, USA 2 Los Alamos National Laboratory Los Alamos, NM, USA 3 Department of Mechanical Engineering University of Utah, Salt Lake City, UT, USA March 27, 2014 GTC 2014, San Jose CA This material is based upon work supported by the National Science Foundation under Grants No. 1133590, 0828206, CBET-PDM 113458, EPS 1208732, and AGS 1255662. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Upload: trinhthien

Post on 29-May-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

QUIC EnvSim: Radiative Heat Transfer in Vegetative and UrbanEnvironments with NVIDIA OptiX

Matthew Overby1

Scot Halverson2, Brian Bailey3, Pete Willemsen1, Rob Stoll3, Eric Pardyjak3

1Department of Computer Science University of Minnesota Duluth, Duluth, MN, USA

2Los Alamos National Laboratory Los Alamos, NM, USA

3Department of Mechanical Engineering University of Utah, Salt Lake City, UT, USA

March 27, 2014GTC 2014, San Jose CA

This material is based upon work supported by the National Science Foundation under Grants No. 1133590, 0828206, CBET-PDM 113458, EPS 1208732, and AGS 1255662.Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National ScienceFoundation.

NVIDIA OptiX Ray Tracing Engine

NVIDIA OptiX:

GPU-accelerated raytracing engine

Versitile and flexible

Ray Tracing: Tracking a ray through a virtualenvironment by using ray surface intersections tests

2/31 Matt Overby - Urban Radiation Transfer with OptiX

QUIC EnvSim and the GEnUSiS Project

Our goal is to understand the complexinteractions between the environment and

urban form

QUIC EnvSim is a part of the Green Environmental Urban Simulations for Sustainability(GEnUSiS) project: http://d.umn.edu/∼sivelab/project/genusis

3/31 Matt Overby - Urban Radiation Transfer with OptiX

Introduction

Radiation in Urban Domains

Multi-GPU Considerations

4/31 Matt Overby - Urban Radiation Transfer with OptiX

Radiation Transferis a driving force of urban climate

5/31 Matt Overby - Urban Radiation Transfer with OptiX

Material Interactions

6/31 Matt Overby - Urban Radiation Transfer with OptiX

Radiation Equation for Urban Domains

Rnet = R↓PAR + R↓

NIR + R↓` − R↑

` Instead of visible light, we model:

RPAR : Photosynthetically active radiation

RNIR : Near-infrared radiation

R`: Longwave radiation

Radiation is emitted from:

Sun

Sky (diffuse)

Surfaces and Vegetation

7/31 Matt Overby - Urban Radiation Transfer with OptiX

We need to compute the energy at all ground and building surfaces

[image: Incoming solar radiation of downtown Salt Lake City, Utah]

8/31 Matt Overby - Urban Radiation Transfer with OptiX

A Challenger Appears...

Vegetation:

Needed for a realistic urban domain

Grows in complex and irregularshapes

Thousands of different species in acity

9/31 Matt Overby - Urban Radiation Transfer with OptiX

Discretization of Vegetation

Vegetation is discretized into volumes of abitrary size

Branches and leaves are treated as homogenous cells

Can simulate other forms of participating media

Each volume can have unique physical properties

Mesh of cubes = fast intersections

10/31 Matt Overby - Urban Radiation Transfer with OptiX

Scattering Phase Function

Scattering Phase Function:

Determines direction of scattered energy

Dependent on:

Incoming ray angleRadiation wavelengthLeaf angle distributionTransmissivity, absorptivity, and reflectivity

11/31 Matt Overby - Urban Radiation Transfer with OptiX

Step 1: Absorption and Transmission

(1) Rays continue to transmit until they run out of energy

A fraction of the energy is absorbed and transmitted

Scattered is stored for later based on ray angle (”to-be-scattered energy”)

This allows energy to reach into dense canopies

12/31 Matt Overby - Urban Radiation Transfer with OptiX

Step 2: Scattering

(2) To-be-scattered energy is emitted from all volumes

Each ray’s energy is adjusted according to scattering phase function

Reduces computation by scattering all energy at once

Go back to (1), repeat until all energy has been absorbed somewhere

13/31 Matt Overby - Urban Radiation Transfer with OptiX

Introduction

Radiation in Urban Domains

Multi-GPU Considerations

14/31 Matt Overby - Urban Radiation Transfer with OptiX

Memory in OptiX

Buffers:

Temporary arrays for transferring data between host and device

Can be defined as INPUT, OUTPUT, or INPUT OUTPUT

In QUIC EnvSim:

Many input-output buffers to store absorbed energy

Both host and device need read and write access

15/31 Matt Overby - Urban Radiation Transfer with OptiX

Concurrent Writes

A common problem during absorption:

Multiple rays can hit the sameobjects at the same time

Atomic addition locks memorylocation

Ray Y must wait for Ray X to finishwriting to buffer index of Patch 1

16/31 Matt Overby - Urban Radiation Transfer with OptiX

Multiple GPUs

Default:RT BUFFER OUTPUT andRT BUFFER INPUT OUTPUTare stored on the host

Problems:

Atomics not guaranteed acrossmultiple GPUs

Slow read and write access

17/31 Matt Overby - Urban Radiation Transfer with OptiX

Flag Buffers with RT BUFFER GPU LOCAL

Note: You can only do this with INPUT OUTPUT buffers

18/31 Matt Overby - Urban Radiation Transfer with OptiX

Device Local Buffers

Benefits:Each device has local copy

Atomics guaranteed

Faster reads and writes

Caveats:Now have different copies of the same buffer

Host no longer has read access through OptiX

Must post-process with CUDA

19/31 Matt Overby - Urban Radiation Transfer with OptiX

Post-Process with CUDA

(A) Energy is seperately and atomically written to on each device(B) Copy all buffers to one device(C) Join (for absorption we sum) with CUDA(D) Distribute joined buffer to all devices, and deallocate copies

20/31 Matt Overby - Urban Radiation Transfer with OptiX

Settings:

2 × Tesla S2050

Red: Default buffersettings

Blue: GPU-local buffers

21/31 Matt Overby - Urban Radiation Transfer with OptiX

2 Million Vegetation Volumes

22/31 Matt Overby - Urban Radiation Transfer with OptiX

Typical Use Case of QUIC EnvSim: Diurnal Cycle

Measure net radiation from sun up to sun down

More energy during the day means morecomputational complexity

23/31 Matt Overby - Urban Radiation Transfer with OptiX

Settings:

Red: 1 × Tesla S2050

Green: 2 × Tesla S2050

Blue: 4 × Tesla S2050

24/31 Matt Overby - Urban Radiation Transfer with OptiX

QUIC EnvSim:Simulates the complex interactions between the environment andurban form

Designed to run on personal and professional workstations

25/31 Matt Overby - Urban Radiation Transfer with OptiX

NVIDIA OptiX:Can be used for more than computer graphics

Greatly simplifies GPU-accelerated ray tracing, but-

You still have to be careful with your data

26/31 Matt Overby - Urban Radiation Transfer with OptiX

Thanks for Attending!

Matthew [email protected]

Department of Computer ScienceUniversity of Minnesota Duluth, Duluth, MN, USA

This material is based upon work supported by the National Science Foundation under Grants No. 1133590, 0828206, CBET-PDM 113458, EPS 1208732, and AGS1255662. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views ofthe National Science Foundation.

27/31 Matt Overby - Urban Radiation Transfer with OptiX

Example Code: OptiX

int type = RT_BUFFER_OUPUT | RT_BUFFER_GPU_LOCAL;

optix::Buffer buffer = context->createBuffer( type );

...

optix::Buffer buffer = context[ "output" ]->getBuffer();

buffer->map();

void *buffer_device0 = 0; void *buffer_device1 = 0;

rtBufferGetDevicePointer( optixBuff->get(), 0, &buffer_device0 );

rtBufferGetDevicePointer( optixBuff->get(), 1, &buffer_device1 );

host_sum( n_elements, buffer_device0, buffer_device1 ); \\ Call CUDA Function

\\ Use cudaMemcpyDeviceToHost if you want to...

buffer->unmap();

Note: If rtBufferGetDevicePointer is not called on every GPU, OptiX will copy a buffer’s contents to otherbuffers on the next rtContextLaunch. This can be avoided with RT BUFFER COPY ON DIRTY.

28/31 Matt Overby - Urban Radiation Transfer with OptiX

Example Code: CUDA (post-processing)

void host_sum( int n_elements, void* buffer_device0, void *buffer_device1 ){

...

cudaSetDevice(0); \\ Do sum on device 0

float *gpu1_copy; \\ Need to copy device 1’s data to device 0

cudaMalloc( (void**) &gpu1_copy, 4*n_elements );

cudaMemcpyPeer( gpu1_copy, 0, buffer_device1, 1, 4*n_elements ); \\ (B)

device_sum<<< ... >>>( (float*)buffer_device0, gpu1_copy ); \\ (C)

cudaMemcpyPeer( buffer_device1, 1, buffer_device0, 0, 4*n_elements ); \\ (D)

cudaFree(gpu1_copy); \\ Remember to deallocate copies!

}

__global__ void device_sum( float *buffer_device0, float *buffer_device1 ){

...

float result = buffer_device0[index] + buffer_device1[index];

buffer_device0[index] = result;

}

29/31 Matt Overby - Urban Radiation Transfer with OptiX

Problem: Concurrent Writes

A Simple Solution:

Reduce concurrent writes byincreasing the size of the buffer

Alter the index by subsection

The number of subsections isthe scaling factor:

Minimize to save GPU memory

Optimal value varies with scene andsimulation

30/31 Matt Overby - Urban Radiation Transfer with OptiX

Empirical experiment:

8192 rays per meter2

NVIDIA Quadro 2000 (1GB)

Sun and Sky Viewfactors

Example Sun Viewfactor = 0.5

31/31 Matt Overby - Urban Radiation Transfer with OptiX