Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binomial as a computationally expensive example computing some reasonable quantity of interest. #75

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 4 additions & 51 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,8 @@
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

file(GLOB_RECURSE AMS_CURRENT_EXAMPLE_INCLUDES "*.hpp")

set(AMS_EXAMPLE_SRC ${MINIAPP_INCLUDES} main.cpp app/eos_ams.cpp)


function(ADDExec binary_name definitions)
if (WITH_RZ)
list(APPEND AMS_EXAMPLE_SRC ${RZ_AMS_SOURCES} ${AMS_CURRENT_EXAMPLE_INCLUDES})
endif()

target_include_directories(${binary_name} PRIVATE ${AMS_EXAMPLE_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include)
target_compile_definitions(${binary_name} PRIVATE ${definitions})
target_link_directories(${binary_name} PRIVATE ${AMS_EXAMPLE_LIB_DIRS})
target_link_libraries(${binary_name} PUBLIC AMS ${AMS_EXAMPLE_LIBRARIES})

if (WITH_CUDA)
set_source_files_properties(main.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "--expt-extended-lambda")
set_source_files_properties(app/eos_ams.cpp PROPERTIES LANGUAGE CUDA)
set_source_files_properties(app/eos_ams.cpp PROPERTIES COMPILE_FLAGS "--expt-extended-lambda")
set_target_properties(${binary_name} PROPERTIES CUDA_ARCHITECTURES "${AMS_CUDA_ARCH}")

if (WITH_RZ)
set_source_files_properties(${RZ_AMS_SOURCES} PROPERTIES LANGUAGE CUDA)
set_source_files_properties(${RZ_AMS_SOURCES} PROPERTIES COMPILE_FLAGS "--expt-extended-lambda")
set_property(TARGET ${binary_name} PROPERTY CUDA_SEPARABLE_COMPILATION ON)
endif()

if (WITH_PERFFLOWASPECT)
set_property(SOURCE ${AMS_EXAMPLE_SRC} APPEND_STRING PROPERTY COMPILE_FLAGS " -Xcompiler=-Xclang -Xcompiler=-load -Xcompiler=-Xclang -Xcompiler=${PERFFLOWASPECT_LIB_DIR}/libWeavePass.so")
endif()
endif()
endfunction()

add_executable(no_ams_example ${AMS_EXAMPLE_SRC} ${MINIAPP_INCLUDES})
ADDExec(no_ams_example "${AMS_EXAMPLE_DEFINES}")

list(APPEND AMS_EXAMPLE_DEFINES "-DUSE_AMS")
add_executable(ams_example ${AMS_EXAMPLE_SRC} ${MINIAPP_INCLUDES})
ADDExec(ams_example "${AMS_EXAMPLE_DEFINES}")

if (WITH_WORKFLOW)
set(TRAIN_DEVICE "cpu")
if (WITH_CUDA)
set(TRAIN_DEVICE "gpu")
endif()
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/prune.py" "${CMAKE_CURRENT_BINARY_DIR}/prune.py")
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/train.py" "${CMAKE_CURRENT_BINARY_DIR}/train.py")
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/sub_selection.py" "${CMAKE_CURRENT_BINARY_DIR}/sub_selection.py")
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/example_run.sh" "${CMAKE_CURRENT_BINARY_DIR}/example_run.sh" @ONLY)
add_subdirectory(ideal_gas)
if (WITH_CUDA)
add_subdirectory(bnm_opt)
endif()

27 changes: 27 additions & 0 deletions examples/bnm_opt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021-2023 Lawrence Livermore National Security, LLC and other
# AMSLib Project Developers
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(binomial_options_src binomial_options.cpp kernel.cpp)

function(ADDExec binary_name definitions)
target_include_directories(${binary_name} PUBLIC "${AMS_EXAMPLE_INCLUDES}")
target_compile_definitions(${binary_name} PRIVATE ${definitions})
target_compile_definitions(${binary_name} PRIVATE ${AMS_EXAMPLE_DEFINES})
target_link_directories(${binary_name} PRIVATE ${AMS_EXAMPLE_LIB_DIRS})
target_link_libraries(${binary_name} PUBLIC AMS ${AMS_EXAMPLE_LIBRARIES})

if (WITH_CUDA)
set_source_files_properties(kernel.cpp PROPERTIES LANGUAGE CUDA)
set_target_properties(${binary_name} PROPERTIES CUDA_ARCHITECTURES "${AMS_CUDA_ARCH}")
endif()
endfunction()

add_executable(no_ams_bo ${binomial_options_src} ${MINIAPP_INCLUDES})
ADDExec(no_ams_bo minibude "${AMS_EXAMPLE_DEFINES}")

list(APPEND AMS_EXAMPLE_DEFINES "-DUSE_AMS")
add_executable(ams_bo ${binomial_options_src} ${MINIAPP_INCLUDES})
ADDExec(ams_bo "${AMS_EXAMPLE_DEFINES}")

40 changes: 40 additions & 0 deletions examples/bnm_opt/binomialOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/


#ifndef BINOMIALOPTIONS_COMMON_H
#define BINOMIALOPTIONS_COMMON_H

#include "realtype.h"

////////////////////////////////////////////////////////////////////////////////
// Global types
////////////////////////////////////////////////////////////////////////////////
typedef struct {
real S;
real X;
real T;
real R;
real V;
} TOptionData;


////////////////////////////////////////////////////////////////////////////////
// Global parameters
////////////////////////////////////////////////////////////////////////////////
//Number of time steps
#define NUM_STEPS 2048
//Max option batch size
#define MAX_OPTIONS 1024

#define NUM_ITERATIONS 20

#endif
Loading
Loading