Skip to content

Instantly share code, notes, and snippets.

View philipturner's full-sized avatar
🏠
Working from home

Philip Turner philipturner

🏠
Working from home
View GitHub Profile
/* Analog Control RGB LED Color, Teensyduino Tutorial #4
http://www.pjrc.com/teensy/tutorial4.html
This example code is in the public domain.
*/
// TODO: Save to GitHub gist
const int outPin = 12;
void setup() {
// Next steps:
// - Allow the window to be closed with "Ctrl + W" on Windows.
// - Track keyboard and mouse events, establishing a prototype of the
// 'UserInterface' utility.
// - Decide on how to hide the cursor from the user. Not a trivial decision.
// - Previously, hid when the user entered the window. Because of stability
// issues, the user must press 'Esc' once before the first mouse hide.
// - Afterward, 'Esc' is used to toggle mouse visibility.
// - The mouse is only tracked and connected to camera movements when the
// cursor is hidden.
import Dispatch
import struct Foundation.Date
func performWork(innerIterationCount: Int) -> Float {
var innerIterationSums = [Float](repeating: 0, count: innerIterationCount)
for innerIterationID in 0..<innerIterationCount {
let threadCount: Int = 10
nonisolated(unsafe)
var sharedMemory = [Float](repeating: 0, count: threadCount)
import simd
protocol LinearSystem {
associatedtype Matrix
var matrix: Matrix { get }
associatedtype Solution
func solve(matrix: Matrix) -> Solution
}
@philipturner
philipturner / ElmerMac3.sh
Last active July 21, 2025 13:00
The optimal compile script for Elmer on macOS
# Invoke this script from a terminal where pwd = ElmerCSC/elmerfem/build.
#
# My file hierarchy:
# ~/Documents
# Elmer
# elmer
# bin
# lib
# share
# elmerfem
@philipturner
philipturner / ElmerMac2.md
Last active July 16, 2025 15:26
Reproducing the original successful compilation, with options closer to the main repo's GitHub workflow
(base) philipturner@macbookpro ~ % cmake --system-information
Avoid ctest truncation of output: CTEST_FULL_OUTPUT
========================================================
=== MAIN VARIABLES
========================================================
CMAKE_STATIC_LIBRARY_PREFIX == "lib"
CMAKE_STATIC_LIBRARY_SUFFIX == ".a"
CMAKE_SHARED_LIBRARY_PREFIX == "lib"
CMAKE_SHARED_LIBRARY_SUFFIX == ".dylib"
CMAKE_SHARED_MODULE_PREFIX == "lib"
@philipturner
philipturner / ElmerMac.md
Last active July 16, 2025 14:57
Trying even harder to get Elmer to work on macOS

New suggestions:

Building ElmerFEM for Apple Silicon works in CI. E.g., https://github.com/ElmerCSC/elmerfem/actions/runs/16269780344/job/45934148818

If I understand the error message from ranlib correctly, it says that some of the object files being archived (e.g., biniomod.f90.o) are built for Apple Silicon (16777228). But other objects that had been added to that static library previously had been built for Intel architecture (16777223).

Not sure why that is. Are you building from a fresh build tree? Are you mixing compilers (e.g., Fortran, C, C++) that are building for different targets? Are other object files that you installed for the Intel architecture when you actually try to build for Apple Silicon?
I'm not a macOS user myself. But maybe try re-installing XCode and make sure that you are getting the correct packages and compilers (from MacPorts?).
Don't try to mix tools for Apple Silicon with tools for Intel architecture.

Sequential Throughput Bottlenecks of APM

Parallelism doesn't beat Amdahl's Law. This is the reason simulations requiring a supercomputer never make their way into laptop CAD applications.

Bootstrapping is a sequence of phases, where you use the speed & parallelism of the current phase to fabricate systems that eliminate the current biggest bottleneck.

Objectives

We need to perform sequential chemical steps:

  • Fast (>1 Hz frequency)
@philipturner
philipturner / main.swift
Created June 9, 2025 12:35
Important notes about run loop structure
// Next steps:
// - Understand the structure of the run loop better. [DONE]
// - Write the SwapChain utility for Windows.
// - Reproduce the 1st 3DGEP tutorial using empty render passes.
// - Reproduce the StackOverflow comment (https://stackoverflow.com/a/78501260)
// about rendering with entirely compute commands.
import MolecularRenderer
#if os(macOS)