Skip to content

Instantly share code, notes, and snippets.

View scivision's full-sized avatar
💭
I will be slow to respond.

scivision

💭
I will be slow to respond.
View GitHub Profile
@scivision
scivision / CMakeLists.txt
Last active December 6, 2023 03:05
CMake C++ library and Fortran main program LINKER_LANGUAGE heuristic issue
cmake_minimum_required(VERSION 3.19)
project(link LANGUAGES CXX Fortran)
file(GENERATE OUTPUT lib.cpp CONTENT "extern \"C\" int addtwo(int N){ return N + 2; }")
file(GENERATE OUTPUT main.f90 CONTENT "program adder
use, intrinsic :: iso_c_binding, only : C_INT
@scivision
scivision / CMakeLists.txt
Last active December 3, 2023 19:41
MinGW C++ filesystem glitches
cmake_minimum_required(VERSION 3.10...3.28)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed.
cmake -Bbuild")
endif()
project(fs_unc LANGUAGES CXX)
enable_testing()
@scivision
scivision / Readme.md
Last active November 30, 2023 15:25
Intel oneAPI GitHub Actions (with caching) MKL and MPI (C, C++, Fortran) and CMake

GitHub Actions Intel oneAPI with caching

Using GitHub Actions cache is a little more complicated than not caching, but makes the setup time dramatically shorter.

This example uses MKL and MPI.

Live example with Fortran only (no MKL or MPI).

Reference oneAPI repo

@scivision
scivision / oneapi.sh
Last active November 10, 2023 15:35
oneAPI source script
source /opt/intel/oneapi/setvars.sh
export CC=icx CXX=icpx FC=ifx
export MPI_ROOT=$I_MPI_ROOT
@scivision
scivision / nvidia-hpc.sh
Last active November 17, 2023 19:14
NVIDIA HPC SDK source script (incl. CUDA)
# when wanting to use NVIDIA HPC SDK, type in Terminal
# source ~/nvidia-hpc.sh
nvroot=/opt/nvidia/hpc_sdk/Linux_x86_64/2023/
cudaroot=${nvroot}/cuda/
export PATH=$PATH:${cudaroot}/bin/:${nvroot}/compilers/bin/
export CC=nvc CXX=nvc++ FC=nvfortran
@scivision
scivision / README.md
Last active November 10, 2023 05:35
CUDA Nerf on HPC

Using CUDA on HPC

This example is for BU SCC, but other HPC work similarly.

A couple of the source files take several minutes each to compile--whole build takes about 20 minutes.

NOTE: if you previously loaded other modules, best to logoff and logon to have a known fresh environment.

NVlabs/instant-ngp#1318

@scivision
scivision / vtk_write.c
Created October 29, 2023 13:41
HDF5 VTK example
/* example of VTK HDF5 file format
This is a de facto HDF5 file template using specific group names and dataset hierarchy.
ParaView can also read these VTK HDF5 files.
Build: use the HDF5 compiler wrapper for convenience:
h5cc vtk_write.c -o vtk_demo
./vtk_demo hi.h5
@scivision
scivision / CMakeLists.txt
Last active October 26, 2023 16:51
CMake 3.27.0...3.27.7 Ninja Fortran TARGET_OBJECTS generation bug
cmake_minimum_required(VERSION 3.10)
project(LotOfModules LANGUAGES Fortran)
message(STATUS "CMake ${CMAKE_VERSION}")
add_library(m1 OBJECT m1.f90)
add_library(m2 OBJECT m2.f90)
target_link_libraries(m2 PRIVATE m1)
@scivision
scivision / main.cmake
Created October 23, 2023 14:49
CMAKE_IGNORE_PREFIX_PATH priority glitch
cmake_minimum_required(VERSION 3.23)
set(CMAKE_FIND_DEBUG_MODE true)
# in my opinion, I shouldn't need to set CMAKE_IGNORE_PATH as well.
if(DEFINED ENV{CONDA_PREFIX})
list(APPEND CMAKE_IGNORE_PREFIX_PATH $ENV{CONDA_PREFIX})
list(APPEND CMAKE_IGNORE_PATH $ENV{CONDA_PREFIX}/bin)
endif()
@scivision
scivision / Readme.md
Last active September 27, 2023 01:50
CMake Windows glitch finding exe on PATH with spaces in Path

CMake find_program quirk with spaces in find_* paths

This example is intended for Windows.

Run complete example from top-level script:

cmake -P path.cmake