Skip to content

Commit 10b50f0

Browse files
committed
Fixed Shader Error
Changes to be committed: modified: src/vk/Mlp.def.cc modified: src/vk/cl/Mlp.cl.c modified: src/vk/cl/Mlp.h modified: src/vk/cl/Slp.cl.c modified: src/vk/cl/Slp.h modified: test/vk/MlpTrainHalf-Primal.c modified: test/vk/SlpPredict-Primal.c modified: test/vk/SlpTrain-Primal.c
1 parent 13d75d9 commit 10b50f0

8 files changed

Lines changed: 15 additions & 26 deletions

File tree

src/vk/Mlp.def.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ ae2f_MAC(cllocfloat_t, ) _ae2fVK_AnnMlpMk_imp_V(
371371
1, NULL
372372
, &(v_mk).m_U1.m_clsrc
373373
, ""
374-
"-pod-pushconstant "
375-
"-cl-fast-relaxed-math "
376-
"-cl-single-precision-constant"
377-
378374
, ae2f_const_cast(
379375
char**
380376
, ae2f_reinterpret_cast(

src/vk/cl/Mlp.cl.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma OPENCL EXTENSION cl-fast-relaxed-math : enable
2-
#pragma OPENCL EXTENSION -pod-pushconstant : enable
3-
#pragma OPENCL EXTENSION -cl-fast-relaxed-math : enable
2+
#pragma OPENCL EXTENSION pod-pushconstant : enable
43

54
#define ae2f_NEED_CLASS 0
65

@@ -41,9 +40,9 @@
4140
#define llsz (lsz - 1)
4241

4342
/** @brief lsz * sizeof(uint32_t) */
44-
#define p_layerszlist CAST(__global volatile uint32_t*, glob)
43+
#define p_layerszlist CAST(__global uint32_t*, glob)
4544
/** @brief sizeof(ae2f_float_t) * lsz * pgsz */
46-
#define p_outstream (CAST(__global volatile host_float_t*, p_layerszlist + lsz))
45+
#define p_outstream (CAST(__global host_float_t*, p_layerszlist + lsz))
4746
#define p_inp p_outstream
4847

4948
/** @brief sizeof(ae2f_float_t) * pgsz_sqr * llsz */
@@ -112,7 +111,7 @@ typedef const struct sz2_t {
112111
* ae2f_float_t[Page]: inp
113112
* ae2f_float_t[Page]: out
114113
* */
115-
__kernel void kPredict(__global volatile void* glob, __local volatile ae2f_float_t* loc, sz2_t push) {
114+
__kernel void kPredict(__global void* glob, __local ae2f_float_t* loc, sz2_t push) {
116115
const size_t
117116
oidx = get_global_id(0)
118117
, iidx = get_global_id(1)
@@ -138,7 +137,7 @@ __kernel void kPredict(__global volatile void* glob, __local volatile ae2f_float
138137
* ae2f_float_t[Page]: inp
139138
* ae2f_float_t[Page]: out
140139
* */
141-
__kernel void kPredictStream(__global volatile void* glob, __local volatile ae2f_float_t* loc, const sz2_t push) {
140+
__kernel void kPredictStream(__global void* glob, __local ae2f_float_t* loc, const sz2_t push) {
142141
const size_t
143142
oidx = get_global_id(0)
144143
, iidx = get_global_id(1)
@@ -194,7 +193,7 @@ typedef char STATIC_ASSERT_LRLSZ_SZ[sizeof(lrlsz_t) == sizeof(lrlszel_t) * 4 ?
194193
* ae2f_float_t[lsz - 1][Page]: OutStream
195194
* ae2f_float_t[lsz - 1][Page]: DeltaStream
196195
* */
197-
__kernel void kFollow(__global volatile void* glob, __local volatile ae2f_float_t* loc, lrlsz_t lr) {
196+
__kernel void kFollow(__global void* glob, __local ae2f_float_t* loc, lrlsz_t lr) {
198197
size_t lidx = llsz - 1;
199198
ae2f_float_t v_tmp;
200199

@@ -312,7 +311,7 @@ __kernel void kFollow(__global volatile void* glob, __local volatile ae2f_float_
312311
* ae2f_float_t[lsz - 1][Page]: OutStream
313312
* ae2f_float_t[lsz - 1][Page]: DeltaStream
314313
* */
315-
__kernel void kTrainAuto(__global volatile void* glob, __local volatile ae2f_float_t* loc, lrlsz_t lr) {
314+
__kernel void kTrainAuto(__global void* glob, __local ae2f_float_t* loc, lrlsz_t lr) {
316315
size_t lidx = 0;
317316
const size_t
318317
oidx = get_global_id(0)

src/vk/cl/Mlp.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ ae2f_MAC() clMlpGetHD1(
7979

8080
if((i_oidx) < (i_osz) && (i_iidx) < (i_isz)) {
8181
unless((i_oidx)) (r_delta_then)[i_iidx] = 0;
82-
atomic_add(
83-
&(r_delta_then)[(i_iidx)]
84-
, (i_weight)[(i_isz) * (i_oidx) + (i_iidx)] * (i_delta)[i_oidx]
85-
);
82+
atomic_add(&(r_delta_then)[(i_iidx)], (i_weight)[(i_isz) * (i_oidx) + (i_iidx)] * (i_delta)[i_oidx]);
8683
}
8784
}
8885

src/vk/cl/Slp.cl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma OPENCL EXTENSION cl-fast-relaxed-math : enable
2-
#pragma OPENCL EXTENSION -pod-pushconstant : enable
3-
#pragma OPENCL EXTENSION -cl-fast-relaxed-math : enable
2+
#pragma OPENCL EXTENSION pod-pushconstant : enable
43

54
#define ae2f_NEED_CLASS 0
65

src/vk/cl/Slp.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ ae2f_MAC() clSlpPredict(
2525
if((oidx) < (osz) && (iidx) < (isz)) {
2626
unless((iidx)) (loc)[oidx] = 0;
2727

28-
atomic_add(
29-
&(loc)[oidx]
30-
, (p_weight)[(oidx) * (isz) + (iidx)] * (p_inp)[iidx]
31-
);
28+
atomic_add((loc)[oidx], (p_weight)[(oidx) * (isz) + (iidx)] * (p_inp)[iidx]);
29+
/** (loc)[oidx] += (p_weight)[(oidx) * (isz) + (iidx)] * (p_inp)[iidx]; */
3230

3331
unless(iidx) {
3432
(loc)[oidx] += (p_bias)[oidx];

test/vk/MlpTrainHalf-Primal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static void LossDummy(ae2f_float* a, const ae2f_float* b, const ae2f_float* c, s
1313
return;
1414
}
1515

16-
static size_t s_lpModelLen[] = {2, 10, 3, 12, 1};
16+
static size_t s_lpModelLen[] = {2, 4, 3, 12, 1};
1717

1818
#define NULL_GENERIC(T) ((T*)NULL)
1919

test/vk/SlpPredict-Primal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main() {
4848
, vkphydevmemprops
4949
, NULL
5050
,
51-
"#define CL_Q 1\n"
51+
"#define CL_Q 0\n"
5252
"#define LOSS_DERIV(r, y, y_desired, i, c) \n"
5353
"#define ACT(r, y, i, c) { (*(r) = (1.0 / (1.0 + exp(-y[i])))); } \n"
5454
, "/** This is also a comment */\n"

test/vk/SlpTrain-Primal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ int main() {
3333
__ae2fVK_AnnSlpMk_imp(
3434
mk,
3535
0, 0, 0
36-
, 400, 100, 0, 0
36+
, 1000, 2, 0, 0
3737
, ActDummy, ActDummy, LossDeriv
3838
, 0.1, 0.1
3939
, vkdev
4040
, vkphydevmemprops
4141
, NULL
4242
,
43-
"#define CL_Q 1\n"
43+
"#define CL_Q 0\n"
4444
"#define ACT_DERIV(r, x, i, c) *(r) = (((x)[i] + 1e-7) * (1.0 - (x)[i] - 1e-7)); \n"
4545
"#define ACT(r, x, i, c) *(r) = (1.0 / (1.0 + exp(-(x[i])))); \n"
4646
"#define LOSS_DERIV(r, o, t, i, c) *(r) = ((o)[i] - (t)[i]) / (c);\n"

0 commit comments

Comments
 (0)