Warp Factory
  • What is Warp Factory?
  • Overview
    • Installing Warp Factory
    • Workflow
    • Codebase Structure
    • Object Types
    • Frames
  • Examples
    • Metrics
      • M1 - First Metric
      • M2 - Default Metrics
      • M3 - Building a Metric
    • Energy Tensor
      • T1 - First Energy Tensor
      • T2 - Cartoon Methods
      • T3 - GPU Computation
      • T4 - Solver Order
      • T5 - Errors
    • Analysis
      • A1 - Energy Conditions
      • A2 - Metric Scalars
      • A3 - Eval Metric
      • A4 - Momentum Flow
    • Warp Shell
      • W1 Warp Shell Comoving
  • Modules
    • Metrics Module
      • Metric Library
        • metricGet_Minkowski
        • metricGet_Alcubierre
        • metricGet_Lentz
        • metricGet_VanDenBroeck
        • metricGet_WarpShellComoving
        • metricGet_ModifiedTime
        • metricGet_Schwarzschild
      • Metric Functions
        • setMinkowski
        • setMinkowskiThreePlusOne
        • threePlusOneBuilder
        • threePlusOneDecomposer
    • Analyzer Module
      • getMomentumFlowLines
      • doFrameTransfer
      • changeTensorIndex
      • getScalars
      • getEnergyConditions
      • evalMetric
    • Solver Module
      • getEnergyTensor
      • verifyTensor
    • Visualizer Module
      • plotThreePlusOne
      • plotTensor
      • Plot Functions
    • Units Module
  • General
    • Contributing
    • FAQ
    • Citing Warp Factory
Powered by GitBook
On this page
  • GPU Stress-energy Tensor Computation
  • When to use the GPU?
  • 20x20x20 Grid
  • 60x60x60 Grid
  1. Examples
  2. Energy Tensor

T3 - GPU Computation

GPU Stress-energy Tensor Computation

Requires MATLABs GPU toolbox

%% Alcubierre
gridSize = [1 20 20 20];
worldCenter = (gridSize+1)./2;
velocity = 0.5;
R = 5;
sigma = 0.5;
Metric = metricGet_AlcubierreComoving(gridSize,worldCenter,velocity,R,sigma);

% Compute energy tensor on GPU
EnergyTensorGPU = getEnergyTensor(Metric,1); % Note the 1 as a second input arg

% Plotting Energy Tensor
clf
for i = 1:4
    for j = 1:4
        h = nexttile;
        surfq(EnergyTensorGPU.tensor{i,j}(1,:,:,round(worldCenter(4))),'EdgeColor','none')
        title(num2str(i) + "," + num2str(j))
    end
end
sgtitle(Metric.name + " Energy Tensor")

When to use the GPU?

20x20x20 Grid

%% Alcubierre For 20*20*20
gridSize = [1 20 20 20];
worldCenter = (gridSize+1)./2;
velocity = 0.5;
R = 5;
sigma = 0.5;
Metric = metricGet_AlcubierreComoving(gridSize,worldCenter,velocity,R,sigma);

% Compute energy tensor on GPU
tic
EnergyTensorGPU = getEnergyTensor(Metric,1);
toc

% Compute energy tensor on CPU
tic
EnergyTensor = getEnergyTensor(Metric,0);
toc

CPU takes a shorter time for smaller grids.

60x60x60 Grid

%% Alcubierre For 60*60*60
gridSize = [1 60 60 60];
worldCenter = (gridSize+1)./2;
velocity = 0.5;
R = 5;
sigma = 0.5;
Metric = metricGet_AlcubierreComoving(gridSize,worldCenter,velocity,R,sigma);

% Compute energy tensor on GPU
tic
EnergyTensorGPU = getEnergyTensor(Metric,1);
toc

% Compute energy tensor on CPU
tic
EnergyTensor = getEnergyTensor(Metric,0);
toc

GPU takes a shorter time for larger grids.

There is an upper limit to the gridSize of metrics that you can compute using the GPU. This will depend on how much memory your GPU has.

Whether you should run an evaluation on the CPU vs. the GPU will depend on your specific CPU and GPU. Below grid sizes of about 30 to 50 cubic units, the CPU should be used for maximum speed. Above this range, faster computation will be done by the GPU up to the GPU memory limit for your specific GPU. Above this GPU limit, CPU computation will need to be done up to your machine's CPU memory limit.

These large CPU computations will take a very long time.

PreviousT2 - Cartoon MethodsNextT4 - Solver Order

Last updated 1 year ago