This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from random import random, choices | |
| def clip(x, x0, x1): | |
| return x0 if x < x0 else x1 if x > x1 else x | |
| def make_masks(geneSize, popSize, crossoverNum): | |
| mask0 = [0] * geneSize | |
| mask1 = [int(i / int(geneSize / crossoverNum)) % 2 for i in range(geneSize)] | |
| mask2 = [-x for x in mask1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function reduce(arr, fn) { | |
| let tasks = arr.map(item => ({ item })), | |
| reqs = [] | |
| while (true) { | |
| if (tasks.length === 1) { | |
| return tasks[0].item | |
| } | |
| const toRun = tasks.filter(task => !task.started) | |
| for (let i = 0; i + 1 < toRun.length; i += 2) { | |
| const [a, b] = toRun.slice(i, i + 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
| <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
| <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
| <script src="index.jsx" type="text/babel"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.18) | |
| project(binding) | |
| if(WIN32) | |
| set(CUDA_NVCC_FLAGS -Xcompiler;"/MD /wd 4819") | |
| endif() | |
| find_package(CUDA REQUIRED) | |
| include_directories(${CMAKE_JS_INC} "${CMAKE_SOURCE_DIR}/include") | |
| file(GLOB SOURCE_FILES "src/*.cu") | |
| cuda_add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC}) | |
| set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cluster = require('cluster'), | |
| os = require('os') | |
| class Worker { | |
| destroyed = false | |
| /** @type { { [id: string]: { id: string, func: Function, args: any[], resolve: Function, reject: Function } } } */ | |
| calls = { } | |
| /** @type { import('cluster').Worker } */ | |
| worker = this.fork() | |
| fork() { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <style> | |
| svg { | |
| user-select: none; | |
| } | |
| svg polygon { | |
| fill: chocolate; | |
| } | |
| svg circle { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| // Reference: | |
| // https://nosferalatu.com/SimpleGPUHashTable.html | |
| // replace the function with cuda implement | |
| unsigned long atomicCAS(unsigned long *addr, unsigned long comp, unsigned long val) { | |
| auto prev = *addr; | |
| if (*addr == comp) { | |
| *addr = val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nano /etc/sysctl.conf | |
| # uncomment the following line | |
| # net.ipv4.ip_forward=1 | |
| sysctl -p | |
| iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rem update blas dir and cuda version | |
| set BLAS_DIR=D:\Programs\OpenBLAS-0.3.7-x64 | |
| set CUDA_PREFIX=cuda100 | |
| set OUTPUT_EXE=build\main | |
| set MAGMA_DIR=%~dp0\build\magma | |
| if not exist %MAGMA_DIR% ( | |
| rem using static library precompiled for pytorch | |
| rem https://github.com/pytorch/pytorch/blob/master/docs/source/notes/windows.rst |