Skip to content

Commit

Permalink
Set up GPU process
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Nov 8, 2024
1 parent 3965319 commit d220c66
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 176 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ endif()
# GPU
if(VIENNAPS_BUILD_GPU_APPLICATION)
message(STATUS "[ViennaPS] Building GPU Application")
add_subdirectory(GPU)
add_subdirectory(gpu)
endif(VIENNAPS_BUILD_GPU_APPLICATION)

# --------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions app/application.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "application.hpp"
#include "interrupt.hpp"

int main(int argc, char **argv) {

Expand Down
1 change: 0 additions & 1 deletion app/applicationParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <string>
#include <unordered_map>

#include <psLogger.hpp>
#include <psMaterials.hpp>
#include <psUtils.hpp>
#include <vcLogger.hpp>
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 12 additions & 10 deletions gpu/cmake/configure_optix.cmake → cmake/configure_optix.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# ======================================================================== # Copyright 2018 Ingo
# Wald # # Licensed under the Apache License,
# Version 2.0 (the "License"); # you may not use this file except in compliance with the
# License. # You may obtain a copy of the License at # #
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by
# applicable law or agreed to in writing, software # distributed under the License is
# distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. # See the License for the specific language governing permissions and #
# limitations under the License. #
# ========================================================================
# Copyright 2018 Ingo Wald
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing permissions and
# limitations under the License.
# ======================================================================== #

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

message(STATUS "OptiX_INSTALL_DIR: ${OptiX_INSTALL_DIR}")

find_package(CUDA REQUIRED)
find_package(OptiX REQUIRED)
# find_package(OptiX REQUIRED)

message(STATUS "Found OptiX at: " ${OptiX_INSTALL_DIR})

Expand Down
115 changes: 46 additions & 69 deletions gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,28 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(ViennaPSGPUApplication)

find_package(ViennaPS CONFIG PATHS ${ViennaPS_BINARY_DIR})
if(NOT ViennaPS_FOUND)
message(
FATAL_ERROR
"One of the dependencies hasn't been built yet and thus can't be used by the buildExamples target.\n\
Try the following steps to fix the problem:\n\
1. Turn off the buildExamples target by disabling the VIENNAPS_BUILD_EXAMPLES option when configuring the project\n\
(e.g. with the `-D VIENNAPS_BUILD_EXAMPLES=OFF` flag)\n\
2. Build the dependencies target: e.g. `make buildDependencies` when using Makefiles\n\
3. Turn on the buildExamples target again by re-enabling the VIENNAPS_BUILD_EXAMPLES option\n\
(e.g. with the `-D VIENNAPS_BUILD_EXAMPLES=ON` flag)\n\
4. Now the configure step should pick up the built dependencies and proceed as intended.")
endif()

list(PREPEND VIENNAPS_INCLUDE_DIRS ${VIENNAPS_BUILD_INCLUDE_DIRS})

# Add subfolders to the include directories, since during installation the directory structure is
# flattened, but in the source tree - which we are using here - it is not.
list(PREPEND VIENNAPS_INCLUDE_DIRS ${VIENNAPS_BUILD_INCLUDE_DIRS}/CellSet
${VIENNAPS_BUILD_INCLUDE_DIRS}/Geometries ${VIENNAPS_BUILD_INCLUDE_DIRS}/Models
${VIENNAPS_BUILD_INCLUDE_DIRS}/Compact)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE)

if("${is_cached}" STREQUAL "" AND DEFINED OptiX_INSTALL_DIR)
# Required for windows to convert backslashes to forward slashes
file(TO_CMAKE_PATH "${OptiX_INSTALL_DIR}" OptiX_INSTALL_DIR)
set(OptiX_INSTALL_DIR
"${OptiX_INSTALL_DIR}"
CACHE PATH "Path to OptiX installation" FORCE)
else()
set(OptiX_INSTALL_DIR
$ENV{OptiX_INSTALL_DIR}
CACHE PATH "Path to OptiX installation.")
endif()
include(cmake/configure_optix.cmake)
# if("${is_cached}" STREQUAL "" AND DEFINED OptiX_INSTALL_DIR)
# # Required for windows to convert backslashes to forward slashes
# file(TO_CMAKE_PATH "${OptiX_INSTALL_DIR}" OptiX_INSTALL_DIR)
# set(OptiX_INSTALL_DIR
# "${OptiX_INSTALL_DIR}"
# CACHE PATH "Path to OptiX installation" FORCE)
# else()
# set(OptiX_INSTALL_DIR
# $ENV{OptiX_INSTALL_DIR}
# CACHE PATH "Path to OptiX installation.")
# endif()
set(OptiX_INSTALL_DIR "/home/tobias/OptiX" CACHE PATH "Path to OptiX installed location.")
set(OptiX_INCLUDE "${OptiX_INSTALL_DIR}/include")
message(STATUS "OptiX_INSTALL_DIR: ${OptiX_INSTALL_DIR}")
message(STATUS "OptiX_INCLUDE: ${OptiX_INCLUDE}")
include(${CMAKE_SOURCE_DIR}/cmake/configure_optix.cmake)

set(VIENNAPS_GPU_INCLUDE_DIRS #
${CMAKE_SOURCE_DIR}/app
${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/geometry ${PROJECT_SOURCE_DIR}/process
${PROJECT_SOURCE_DIR}/rayTracing ${PROJECT_SOURCE_DIR}/utils ${PROJECT_SOURCE_DIR}/app)

Expand Down Expand Up @@ -74,52 +55,48 @@ foreach(kernel ${kernels})
add_dependencies(buildGPUApplication ${kernelName})
endforeach()

cuda_compile_and_embed(embedded_SF6O2_pipeline ${PROJECT_SOURCE_DIR}/pipelines/SF6O2Pipeline.cu)
cuda_compile_and_embed(embedded_Fluorocarbon_pipeline
${PROJECT_SOURCE_DIR}/pipelines/FluorocarbonPipeline.cu)
# cuda_compile_and_embed(embedded_SF6O2_pipeline ${PROJECT_SOURCE_DIR}/pipelines/SF6O2Pipeline.cu)
# cuda_compile_and_embed(embedded_Fluorocarbon_pipeline
# ${PROJECT_SOURCE_DIR}/pipelines/FluorocarbonPipeline.cu)

cuda_compile_and_embed(embedded_deposition_pipeline
${PROJECT_SOURCE_DIR}/pipelines/DepositionPipeline.cu)
add_compile_definitions(GPU_SUPPORT)

add_executable(
ViennaPS_GPU ${embedded_SF6O2_pipeline} ${embedded_deposition_pipeline}
${embedded_Fluorocarbon_pipeline} ${PROJECT_SOURCE_DIR}/app/pscuApplication.cpp)

target_include_directories(ViennaPS_GPU PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)

target_link_libraries(ViennaPS_GPU ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${VIENNAPS_LIBRARIES})
${embedded_Fluorocarbon_pipeline} ${PROJECT_SOURCE_DIR}/app/gpuApplication.cpp)
target_include_directories(ViennaPS_GPU PUBLIC ${OptiX_INCLUDE} ${VIENNAPS_GPU_INCLUDE_DIRS})
target_link_libraries(ViennaPS_GPU ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ViennaPS)

add_dependencies(buildGPUApplication ViennaPS_GPU)

### BENCHMARK ###

add_executable(ViennaPS_GPU_Benchmark ${embedded_deposition_pipeline}
${PROJECT_SOURCE_DIR}/benchmark/GPU_Benchmark.cpp)

target_include_directories(
ViennaPS_GPU_Benchmark PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
# add_executable(ViennaPS_GPU_Benchmark ${embedded_deposition_pipeline}
# ${PROJECT_SOURCE_DIR}/benchmark/GPU_Benchmark.cpp)

target_link_libraries(ViennaPS_GPU_Benchmark ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${VIENNAPS_LIBRARIES})
# target_include_directories(
# ViennaPS_GPU_Benchmark PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
# ${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
# target_link_libraries(ViennaPS_GPU_Benchmark ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ViennaPS)

### EXAMPLES ###

add_custom_target(buildGPUExamples)

add_executable(GPU_Trench ${embedded_SF6O2_pipeline}
${PROJECT_SOURCE_DIR}/examples/trench.cpp)
target_include_directories(
GPU_Trench PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
target_link_libraries(GPU_Trench ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${VIENNAPS_LIBRARIES})
add_dependencies(buildGPUExamples GPU_Trench)

add_executable(GPU_Hole ${embedded_SF6O2_pipeline}
${PROJECT_SOURCE_DIR}/examples/hole.cpp)
target_include_directories(
GPU_Hole PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
target_link_libraries(GPU_Hole ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${VIENNAPS_LIBRARIES})
add_dependencies(buildGPUExamples GPU_Hole)
# add_custom_target(buildGPUExamples)

# add_executable(GPU_Trench ${embedded_SF6O2_pipeline}
# ${PROJECT_SOURCE_DIR}/examples/trench.cpp)
# target_include_directories(
# GPU_Trench PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
# ${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
# target_link_libraries(GPU_Trench ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ViennaPS)
# add_dependencies(buildGPUExamples GPU_Trench)

# add_executable(GPU_Hole ${embedded_SF6O2_pipeline}
# ${PROJECT_SOURCE_DIR}/examples/hole.cpp)
# target_include_directories(
# GPU_Hole PUBLIC ${VIENNAPS_INCLUDE_DIRS} ${OptiX_INCLUDE}
# ${VIENNAPS_GPU_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/app)
# target_link_libraries(GPU_Hole ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${VIENNAPS_LIBRARIES})
# add_dependencies(buildGPUExamples GPU_Hole)
1 change: 1 addition & 0 deletions gpu/app/gpuApplication.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "gpuApplication.hpp"
#include "interrupt.hpp"

int main(int argc, char **argv) {

Expand Down
133 changes: 70 additions & 63 deletions gpu/app/gpuApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

#include "context.hpp"

#include "Application.hpp"
#include "application.hpp"

#include <SF6O2Etching.hpp>
// #include <SF6O2Etching.hpp>

#include <pscuProcess.hpp>
#include <pscuProcessPipelines.hpp>

namespace viennaps {

class gpuApplication : public Application<DIM> {
pscuContext context;
gpuContext context;

public:
gpuApplication(int argc, char **argv) : Application(argc, argv) {
std::cout << "Initializing CUDA and OptiX ... ";
pscuCreateContext(context);
CreateContext(context);
std::cout << "success" << std::endl;
}

protected:
void runSimpleDeposition(
psSmartPointer<psDomain<NumericType, DIM>> processGeometry,
psSmartPointer<ApplicationParameters> processParams) override {
void runSingleParticleProcess(
SmartPointer<viennaps::Domain<NumericType, DIM>> processGeometry,
SmartPointer<ApplicationParameters> processParams) override {

// copy top layer for deposition
processGeometry->duplicateTopLevelSet(processParams->material);
Expand All @@ -34,11 +36,10 @@ class gpuApplication : public Application<DIM> {
processParams->cosinePower};
depoParticle.dataLabels.push_back("depoRate");

auto surfModel =
psSmartPointer<SimpleDepositionImplementation::SurfaceModel<
NumericType, DIM>>::New(processParams->rate);
auto velField = psSmartPointer<psDefaultVelocityField<NumericType>>::New(2);
auto model = psSmartPointer<pscuProcessModel<NumericType>>::New();
auto surfModel = SmartPointer<SimpleDepositionImplementation::SurfaceModel<
NumericType, DIM>>::New(processParams->rate);
auto velField = SmartPointer<DefaultVelocityField<NumericType>>::New(2);
auto model = SmartPointer<pscuProcessModel<NumericType>>::New();

model->insertNextParticleType(depoParticle);
model->setSurfaceModel(surfModel);
Expand All @@ -54,56 +55,60 @@ class gpuApplication : public Application<DIM> {
process.apply();
}

void runSF6O2Etching(
psSmartPointer<psDomain<NumericType, DIM>> processGeometry,
psSmartPointer<ApplicationParameters> processParams) override {
curtParticle<NumericType> ion{.name = "ion",
.numberOfData = 3,
.cosineExponent = processParams->ionExponent,
.meanIonEnergy = processParams->ionEnergy,
.sigmaIonEnergy =
processParams->sigmaIonEnergy,
.A_O = processParams->A_O};
ion.dataLabels.push_back("ionSputteringRate");
ion.dataLabels.push_back("ionEnhancedRate");
ion.dataLabels.push_back("oxygenSputteringRate");

curtParticle<NumericType> etchant{.name = "etchant", .numberOfData = 2};
etchant.dataLabels.push_back("etchantRate");
etchant.dataLabels.push_back("sticking_e");

curtParticle<NumericType> oxygen{.name = "oxygen", .numberOfData = 2};
oxygen.dataLabels.push_back("oxygenRate");
oxygen.dataLabels.push_back("sticking_o");

auto surfModel =
psSmartPointer<SF6O2Implementation::SurfaceModel<NumericType, DIM>>::
New(processParams->ionFlux, processParams->etchantFlux,
processParams->oxygenFlux, processParams->etchStopDepth);
auto velField = psSmartPointer<psDefaultVelocityField<NumericType>>::New(2);
auto model = psSmartPointer<pscuProcessModel<NumericType>>::New();

model->insertNextParticleType(ion);
model->insertNextParticleType(etchant);
model->insertNextParticleType(oxygen);
model->setSurfaceModel(surfModel);
model->setVelocityField(velField);
model->setProcessName("SF6O2Etching");
model->setPtxCode(embedded_SF6O2_pipeline);
// void
// runSF6O2Etching(SmartPointer<psDomain<NumericType, DIM>> processGeometry,
// SmartPointer<ApplicationParameters> processParams) override
// {
// curtParticle<NumericType> ion{.name = "ion",
// .numberOfData = 3,
// .cosineExponent =
// processParams->ionExponent, .meanIonEnergy
// = processParams->ionEnergy, .sigmaIonEnergy
// =
// processParams->sigmaIonEnergy,
// .A_O = processParams->A_O};
// ion.dataLabels.push_back("ionSputteringRate");
// ion.dataLabels.push_back("ionEnhancedRate");
// ion.dataLabels.push_back("oxygenSputteringRate");

pscuProcess<NumericType, DIM> process(context);
process.setDomain(processGeometry);
process.setProcessModel(model);
process.setNumberOfRaysPerPoint(processParams->raysPerPoint);
process.setMaxCoverageInitIterations(10);
process.setProcessDuration(processParams->processTime);
process.setSmoothFlux(processParams->smoothFlux);
process.apply();
}
// curtParticle<NumericType> etchant{.name = "etchant", .numberOfData = 2};
// etchant.dataLabels.push_back("etchantRate");
// etchant.dataLabels.push_back("sticking_e");

// curtParticle<NumericType> oxygen{.name = "oxygen", .numberOfData = 2};
// oxygen.dataLabels.push_back("oxygenRate");
// oxygen.dataLabels.push_back("sticking_o");

// auto surfModel =
// SmartPointer<SF6O2Implementation::SurfaceModel<NumericType,
// DIM>>::New(
// processParams->ionFlux, processParams->etchantFlux,
// processParams->oxygenFlux, processParams->etchStopDepth);
// auto velField =
// SmartPointer<psDefaultVelocityField<NumericType>>::New(2); auto model =
// SmartPointer<pscuProcessModel<NumericType>>::New();

// model->insertNextParticleType(ion);
// model->insertNextParticleType(etchant);
// model->insertNextParticleType(oxygen);
// model->setSurfaceModel(surfModel);
// model->setVelocityField(velField);
// model->setProcessName("SF6O2Etching");
// model->setPtxCode(embedded_SF6O2_pipeline);

// pscuProcess<NumericType, DIM> process(context);
// process.setDomain(processGeometry);
// process.setProcessModel(model);
// process.setNumberOfRaysPerPoint(processParams->raysPerPoint);
// process.setMaxCoverageInitIterations(10);
// process.setProcessDuration(processParams->processTime);
// process.setSmoothFlux(processParams->smoothFlux);
// process.apply();
// }

// void runFluorocarbonEtching(
// psSmartPointer<psDomain<NumericType, DIM>> processGeometry,
// psSmartPointer<ApplicationParameters> processParams) override {
// SmartPointer<psDomain<NumericType, DIM>> processGeometry,
// SmartPointer<ApplicationParameters> processParams) override {

// // insert additional top layer to capture deposition
// processGeometry->duplicateTopLevelSet(psMaterial::Polymer);
Expand All @@ -129,12 +134,12 @@ class gpuApplication : public Application<DIM> {
// etchantPoly.dataLabels.push_back("etchantPolyFlux");

// auto surfModel =
// psSmartPointer<pscuFluorocarbonSurfaceModel<NumericType>>::New(
// SmartPointer<pscuFluorocarbonSurfaceModel<NumericType>>::New(
// context, processParams->ionFlux, processParams->etchantFlux,
// processParams->oxygenFlux, processParams->temperature);
// auto velField =
// psSmartPointer<psDefaultVelocityField<NumericType>>::New(2); auto model =
// psSmartPointer<pscuProcessModel<NumericType>>::New();
// SmartPointer<psDefaultVelocityField<NumericType>>::New(2); auto model =
// SmartPointer<pscuProcessModel<NumericType>>::New();

// model->insertNextParticleType(ion);
// model->insertNextParticleType(etchant);
Expand All @@ -153,4 +158,6 @@ class gpuApplication : public Application<DIM> {
// process.setProcessDuration(processParams->processTime);
// process.apply();
// }
};
};

} // namespace viennaps
Loading

0 comments on commit d220c66

Please sign in to comment.