@rlabs-inc/sparse 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libsparse.dylib +0 -0
- package/native/libsparse.dylib +0 -0
- package/native/sparse.m +21 -2
- package/package.json +8 -3
package/libsparse.dylib
CHANGED
|
Binary file
|
package/native/libsparse.dylib
CHANGED
|
Binary file
|
package/native/sparse.m
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
#import <Metal/Metal.h>
|
|
8
8
|
#include "sparse.h"
|
|
9
9
|
#include <stdlib.h>
|
|
10
|
+
#include <dlfcn.h>
|
|
10
11
|
|
|
11
12
|
// ============================================================================
|
|
12
13
|
// INTERNAL STRUCTURES
|
|
@@ -116,13 +117,31 @@ SparseContextRef sparse_init(void) {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
if (!shaderSource) {
|
|
119
|
-
// Try loading
|
|
120
|
+
// Try loading relative to the dylib location (for npm packages)
|
|
121
|
+
Dl_info info;
|
|
122
|
+
if (dladdr((void*)sparse_init, &info) && info.dli_fname) {
|
|
123
|
+
NSString* dylibPath = [NSString stringWithUTF8String:info.dli_fname];
|
|
124
|
+
NSString* dylibDir = [dylibPath stringByDeletingLastPathComponent];
|
|
125
|
+
|
|
126
|
+
// Try native/sparse.metal (package structure)
|
|
127
|
+
NSString* localPath = [dylibDir stringByAppendingPathComponent:@"native/sparse.metal"];
|
|
128
|
+
shaderSource = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
|
|
129
|
+
|
|
130
|
+
if (!shaderSource) {
|
|
131
|
+
// Try sparse.metal directly next to dylib
|
|
132
|
+
localPath = [dylibDir stringByAppendingPathComponent:@"sparse.metal"];
|
|
133
|
+
shaderSource = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!shaderSource) {
|
|
139
|
+
// Fallback: Try loading from current directory
|
|
120
140
|
NSString* currentDir = [[NSFileManager defaultManager] currentDirectoryPath];
|
|
121
141
|
NSString* localPath = [currentDir stringByAppendingPathComponent:@"native/sparse.metal"];
|
|
122
142
|
shaderSource = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
|
|
123
143
|
|
|
124
144
|
if (!shaderSource) {
|
|
125
|
-
// Try relative to library location
|
|
126
145
|
localPath = [currentDir stringByAppendingPathComponent:@"sparse.metal"];
|
|
127
146
|
shaderSource = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:nil];
|
|
128
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlabs-inc/sparse",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Sparsity-first GPU compute for biological neural simulation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
"build": "bun build src/index.ts --outdir dist --target node",
|
|
17
17
|
"build:native": "cd native && make"
|
|
18
18
|
},
|
|
19
|
-
"os": [
|
|
20
|
-
|
|
19
|
+
"os": [
|
|
20
|
+
"darwin"
|
|
21
|
+
],
|
|
22
|
+
"cpu": [
|
|
23
|
+
"arm64",
|
|
24
|
+
"x64"
|
|
25
|
+
],
|
|
21
26
|
"keywords": [
|
|
22
27
|
"gpu",
|
|
23
28
|
"metal",
|