Skip to content

Commit 17853c9

Browse files
Make it actually compile (#27)
1 parent 40bb9c1 commit 17853c9

File tree

14 files changed

+111
-59
lines changed

14 files changed

+111
-59
lines changed

dub.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"derelict-cuda": "~>2.0.1",
1010
"taggedalgebraic": "~>0.10.7"
1111
},
12-
"dflags" : ["-mdcompute-targets=cuda-350" , "-vv", "-oq", "-betterC"]
12+
"dflags" : ["-mdcompute-targets=cuda-350" , "-oq", "-betterC"]
1313
}

source/dcompute/driver/cuda650/buffer.d renamed to source/dcompute/driver/cuda/buffer.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module dcompute.driver.cuda650.buffer;
1+
module dcompute.driver.cuda.buffer;
2+
3+
import dcompute.driver.cuda;
24

35
struct Buffer(T)
46
{
@@ -10,3 +12,5 @@ struct Buffer(T)
1012
checkErrors();
1113
}
1214
}
15+
16+
alias bf = Buffer!float;

source/dcompute/driver/cuda650/context.d renamed to source/dcompute/driver/cuda/context.d

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
module dcompute.driver.cuda650.context;
1+
module dcompute.driver.cuda.context;
2+
3+
import dcompute.driver.cuda;
24

35
struct Context
46
{
57
void* raw;
68
this(Device dev, uint flags)
79
{
8-
status = cast(Status)cuCtxCreate(&raw, flags,dev);
10+
status = cast(Status)cuCtxCreate(&raw, flags,dev.raw);
911
checkErrors();
1012
}
1113

@@ -20,15 +22,17 @@ struct Context
2022
Context ret;
2123
status = cast(Status)cuCtxPopCurrent(&ret.raw);
2224
checkErrors();
25+
return ret;
2326
}
24-
static Context @property current()
27+
static @property Context current()
2528
{
2629
Context ret;
2730
status = cast(Status)cuCtxGetCurrent(&ret.raw);
2831
checkErrors();
32+
return ret;
2933
}
3034

31-
static void @property current(Context ctx)
35+
static @property void current(Context ctx)
3236
{
3337
status = cast(Status)cuCtxSetCurrent(ctx.raw);
3438
checkErrors();
@@ -49,13 +53,13 @@ struct Context
4953
deviceRuntimePendingLaunchCount
5054
}
5155

52-
static void @property limit(Limit what)(size_t lim)
56+
static @property void limit(Limit what)(size_t lim)
5357
{
5458
status = cast(Status)cuCtxSetLimit(what,lim);
5559
checkErrors();
5660
}
5761

58-
static size_t @property limit(Limit what)()
62+
static @property size_t limit(Limit what)()
5963
{
6064
size_t ret;
6165
status = cast(Status)cuCtxSetLimit(&ret,what);
@@ -81,15 +85,15 @@ struct Context
8185
static @property CacheConfig cacheConfig()
8286
{
8387
CacheConfig ret;
84-
status = cast(Status)cuCtxSetSharedMemConfig(&ret);
88+
status = cast(Status)cuCtxGetSharedMemConfig(cast(int*)&ret);
8589
checkErrors();
8690
return ret;
8791
}
8892

8993
@property uint apiVersion()
9094
{
9195
uint ret;
92-
status = cast(Status)cuCtxGetApiVersion(&ret);
96+
status = cast(Status)cuCtxGetApiVersion(raw,&ret);
9397
checkErrors();
9498
return ret;
9599
}

source/dcompute/driver/cuda650/device.d renamed to source/dcompute/driver/cuda/device.d

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module dcompute.driver.cuda650.device;
1+
module dcompute.driver.cuda.device;
2+
3+
import dcompute.driver.cuda;
24

35
struct Device
46
{
@@ -90,13 +92,13 @@ struct Device
9092
@(79) int globalL1CacheSupported;
9193
@(80) int localL1CacheSupported;
9294
@(81) int maxSharedMemoryPerMultiprocessor;
93-
@(82) int maxRegistorsPerMultiprocessor
95+
@(82) int maxRegistorsPerMultiprocessor;
9496
@(83) int managedMemory;
9597
@(84) int multiGPUBoard;
9698
@(85) int multiGPUBoardGroupID;
9799
}
98100

99-
@proprty size_t totalMemory()
101+
@property size_t totalMemory()
100102
{
101103
size_t ret;
102104
status = cast(Status)cuDeviceTotalMem(&ret,raw);

source/dcompute/driver/cuda/event.d

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module dcompute.driver.cuda.event;
2+
3+
import dcompute.driver.cuda;
4+
5+
struct Event
6+
{
7+
void* raw;
8+
9+
}

source/dcompute/driver/cuda650/kernel.d renamed to source/dcompute/driver/cuda/kernel.d

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
module dcompute.driver.cuda650.kernel;
1+
module dcompute.driver.cuda.kernel;
22

3+
import dcompute.driver.cuda;
34
struct Kernel(F) if (is(F==function)|| is(F==void))
45
{
56
void* raw;
@@ -17,13 +18,5 @@ struct Kernel(F) if (is(F==function)|| is(F==void))
1718
@(6) int binaryVersion;
1819
@(7) int cacheModeCa;
1920
}
20-
2121

22-
23-
enum MemoryBankConfig : int
24-
{
25-
default_,
26-
fourBytes,
27-
eightBytes,
28-
}
2922
}

source/dcompute/driver/cuda650/memory.d renamed to source/dcompute/driver/cuda/memory.d

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
module dcompute.driver.cuda650.memory;
1+
module dcompute.driver.cuda.memory;
22

33
import dcompute.driver.error;
4+
import dcompute.driver.cuda;
45

56
// void pointer like
67
struct MemoryPointer
78
{
89
size_t raw;
910
static MemoryPointer allocate(size_t nbytes)
1011
{
11-
Memory ret;
12+
MemoryPointer ret;
1213
status = cast(Status)cuMemAlloc(&ret.raw,nbytes);
1314
checkErrors();
1415
return ret;
@@ -18,8 +19,9 @@ struct MemoryPointer
1819
Memory addressRange()
1920
{
2021
Memory ret;
21-
status = cast(Status)cuMemGetAddressRange(&ret.raw,&ret.length,raw);
22+
status = cast(Status)cuMemGetAddressRange(&ret.ptr.raw,&ret.length,raw);
2223
checkErrors();
24+
return ret;
2325
}
2426

2527
}
@@ -39,6 +41,7 @@ struct Memory
3941

4042
// cuMemcpy and friends
4143
// TODO: implement this properly
44+
/*
4245
template copy(T, CopySource from, CopySource to, int dimentions = 1,
4346
Flag!"peer" _peer = No.peer)
4447
{
@@ -47,7 +50,7 @@ struct Memory
4750
status = cast(Status)cuMemcpy(to.ptr.raw,ptr.raw,length);
4851
checkErrors();
4952
}
50-
}
53+
}*/
5154

5255
// TODO: cuMemset & frineds
5356

source/dcompute/driver/cuda/package.d

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module dcompute.driver.cuda;
2+
3+
public import derelict.cuda.driverapi;
4+
5+
public import dcompute.driver.error;
6+
7+
public import dcompute.driver.cuda.buffer;
8+
public import dcompute.driver.cuda.context;
9+
public import dcompute.driver.cuda.device;
10+
public import dcompute.driver.cuda.event;
11+
public import dcompute.driver.cuda.kernel;
12+
public import dcompute.driver.cuda.memory;
13+
public import dcompute.driver.cuda.platform;
14+
public import dcompute.driver.cuda.program;
15+
public import dcompute.driver.cuda.queue;
16+
17+
enum CopySource
18+
{
19+
host,
20+
device,
21+
array,
22+
}
23+
24+
enum MemoryBankConfig : int
25+
{
26+
default_,
27+
fourBytes,
28+
eightBytes,
29+
}

source/dcompute/driver/cuda650/platform.d renamed to source/dcompute/driver/cuda/platform.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
module dcompute.driver.cuda650.platform;
1+
module dcompute.driver.cuda.platform;
22

33
import dcompute.driver.error;
4-
import std.allocator.typed;
4+
import dcompute.driver.cuda;
5+
import std.experimental.allocator.typed;
56

67
struct Platform
78
{

0 commit comments

Comments
 (0)