Skip to content

Instantly share code, notes, and snippets.

View Hermann-SW's full-sized avatar

Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
@Hermann-SW
Hermann-SW / hip-magic.cpp
Created July 7, 2025 19:23
Compare single thread pure integer performance of CPUs and [AMD] GPUs
/*
Compare single thread pure integer performance of CPUs and [AMD] GPUs
hipcc hip-magic.hip
cpplint --filter=-legal/copyright hip-magic.hip.cpp
cppcheck --enable=all --suppress=missingIncludeSystem hip-magic.hip.cpp --check-config
*/
#include <sys/time.h>
#include <stdint.h>
#include <hip/hip_runtime.h>
@Hermann-SW
Hermann-SW / dummy.txt
Last active July 10, 2025 19:38
OpenCL example notes
see comments
@Hermann-SW
Hermann-SW / pcb442.cpp
Last active July 11, 2025 20:29
TSP Ruin and Recreate greedy implementation with random+sequential+radial ruins
/*
TSP Ruin and Recreate greedy implementation with random+sequential+radial ruins:
https://www.semanticscholar.org/paper/Record-Breaking-Optimization-Results-Using-the-Ruin-Schrimpf-Schneider/4f80e70e51e368858c3df0787f05c3aa2b9650b4
c++ -O3 -std=c++17 -Wall -Wextra -pedantic pcb442.cpp -o pcb442 -lstdc++ -lm
(tested with g++ and clang++)
for tour display
- append compiler flags "-Dezxdisp -lezx -lX11"
- after "make install" of ezxdisp repo first:
@Hermann-SW
Hermann-SW / range_http.c
Created June 23, 2025 17:38
single threaded http server for distribution of disjoint bases from a range to geneferg on many CPUs/GPUs
/* based on:
https://medium.com/@justup1080/tutorial-creating-a-minimalist-http-server-in-c-2303d140c725
gcc -Wall -Wextra -pedantic range_http.c -o range_http
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <netinet/in.h>
@Hermann-SW
Hermann-SW / amdgpu_temp
Created June 11, 2025 20:08
Table display of three temperatures for all installed AMD GPUs every second
#!/bin/bash
d=$(find /sys/class/drm/card?/device/unique_id | wc --l)
printf "%9s" "$(hostname)"
for((c=0;c<d;++c))
do
printf "|%s" "$(cat /sys/class/drm/card$c/device/unique_id)"
done
echo "|"
@Hermann-SW
Hermann-SW / demo_executions.md
Last active June 1, 2025 09:47
Fast discrete log() allows factoring RSA semiprimes easily

See comment below.

@Hermann-SW
Hermann-SW / C60.Hamilton_Cycle.jscad
Created May 28, 2025 23:25
JSCAD script console.logs Mathematica command FindHamiltonianCycle[...], and displays its results in JSCAD
"use strict"
const jscad = require('@jscad/modeling')
const { translate, rotate, scale:scale3d } = jscad.transforms
const { vec3 } = jscad.maths
const { colorize } = jscad.colors
const { sphere, cylinder } = jscad.primitives
const { add, length, subtract, scale } = jscad.maths.vec3
const phi=(Math.sqrt(5)+1)/2;
const build=[[0,1,3*phi],[1,2+phi,2*phi],[phi,2,2*phi+1]];
@Hermann-SW
Hermann-SW / utility.jscad
Last active June 15, 2025 15:32
K_{3,3} embedded on a Möbius strip (with Bezier curve edges)
"use strict";
const jscad = require("@jscad/modeling");
const { vec2, vec3} = jscad.maths;
const { bezier} = jscad.curves;
const { rotate, scale, translate } = jscad.transforms;
const { cuboid, sphere, cylinder } = jscad.primitives;
const { colorize } = jscad.colors;
const r=40;
const w=20;
@Hermann-SW
Hermann-SW / measure.gp
Created May 17, 2025 23:03
script demonstrating alternative for isprimepower() with very big primes
f1(N)={isprimepower(N,&r);return(r);}
f2(N)={return(lift(gcd(Mod(2,N)^N-2,N)));}
measure(f,N)={t0=getwalltime();f(N);t1=getwalltime();return(t1-t0);}
print("runtimes in milliseconds, with N=nextprime(base)^expo\n");
print("isprimepower(N,&r);return(r)");
{
printf(" |");for(e=2,15,printf("%3d|",e));print();
@Hermann-SW
Hermann-SW / E.jscad
Created April 27, 2025 14:56
part to join with a 2GPU Riser card model
"use strict"
const jscad = require('@jscad/modeling')
const { translate, rotateZ } = jscad.transforms
const { cuboid, sphere } = jscad.primitives
function main() {
return rotateZ(Math.PI/2,[
cuboid({size: [70,10,10]}),
translate([0,50,0], cuboid({size: [70,10,10]})),
translate([0,100,0], cuboid({size: [70,10,10]})),