Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
docking
ocladock-fpga
Commits
1ca1d501
Commit
1ca1d501
authored
Nov 15, 2018
by
Leonardo Solis
Browse files
#36, first commit (swemu OK) of tradition GA with sdx174
parent
db054c9a
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
ofdock_taskpar_xl/Makefile
View file @
1ca1d501
...
...
@@ -25,25 +25,6 @@ ENABLE_KERNELS = -DENABLE_KRNL_GA \
-DENABLE_KRNL_PRNG_BT_USHORT_FLOAT
\
-DENABLE_KRNL_PRNG_GG_UCHAR
\
-DENABLE_KRNL_PRNG_GG_FLOAT
\
-DENABLE_KRNL_PRNG_LS123_USHORT
\
-DENABLE_KRNL_PRNG_LS_FLOAT
\
-DENABLE_KRNL_PRNG_LS2_FLOAT
\
-DENABLE_KRNL_PRNG_LS3_FLOAT
\
-DENABLE_KRNL_PRNG_LS4_FLOAT
\
-DENABLE_KRNL_PRNG_LS5_FLOAT
\
-DENABLE_KRNL_PRNG_LS6_FLOAT
\
-DENABLE_KRNL_PRNG_LS7_FLOAT
\
-DENABLE_KRNL_PRNG_LS8_FLOAT
\
-DENABLE_KRNL_PRNG_LS9_FLOAT
\
-DENABLE_KRNL_LS
\
-DENABLE_KRNL_LS2
\
-DENABLE_KRNL_LS3
\
-DENABLE_KRNL_LS4
\
-DENABLE_KRNL_LS5
\
-DENABLE_KRNL_LS6
\
-DENABLE_KRNL_LS7
\
-DENABLE_KRNL_LS8
\
-DENABLE_KRNL_LS9
\
-DENABLE_KRNL_IGL_ARBITER
# Fixed-point
...
...
@@ -51,7 +32,6 @@ ENABLE_KERNELS = -DENABLE_KRNL_GA \
FIXED_POINT_CONFORM
=
NO
FIXED_POINT_INTERE
=
NO
FIXED_POINT_INTRAE
=
NO
FIXED_POINT_ALL_LS
=
NO
ifeq
($(FIXED_POINT_CONFORM), YES)
FIPOCO_FLAG
=
-DFIXED_POINT_CONFORM
...
...
@@ -71,24 +51,9 @@ else
FIPOIA_FLAG
=
endif
ifeq
($(FIXED_POINT_ALL_LS), YES)
FIPO_ALL_LS_FLAG
=
-DFIXED_POINT_LS1
-DFIXED_POINT_LS2
-DFIXED_POINT_LS3
-DFIXED_POINT_LS4
-DFIXED_POINT_LS5
-DFIXED_POINT_LS6
-DFIXED_POINT_LS7
-DFIXED_POINT_LS8
-DFIXED_POINT_LS9
else
FIPO_ALL_LS_FLAG
=
endif
FIPO_FLAG
=
$(FIPOCO_FLAG)
\
$(FIPOIE_FLAG)
\
$(FIPOIA_FLAG)
\
$(FIPOLS1_FLAG)
\
$(FIPOLS2_FLAG)
\
$(FIPOLS3_FLAG)
\
$(FIPOLS4_FLAG)
\
$(FIPOLS5_FLAG)
\
$(FIPOLS6_FLAG)
\
$(FIPOLS7_FLAG)
\
$(FIPOLS8_FLAG)
\
$(FIPOLS9_FLAG)
$(FIPOIA_FLAG)
# Other configs
...
...
ofdock_taskpar_xl/device/Krnl_Conform.cl
View file @
1ca1d501
...
...
@@ -81,15 +81,6 @@ while(active) {
switch
(
mode
)
{
case
'I
'
:
read_pipe_block
(
chan_IC2Conf_genotype,
&fl_tmp
)
; break;
case
'G
'
:
read_pipe_block
(
chan_GG2Conf_genotype,
&fl_tmp
)
; break;
case
0x01:
read_pipe_block
(
chan_LS2Conf_LS1_genotype,
&fl_tmp
)
; break;
case
0x02:
read_pipe_block
(
chan_LS2Conf_LS2_genotype,
&fl_tmp
)
; break;
case
0x03:
read_pipe_block
(
chan_LS2Conf_LS3_genotype,
&fl_tmp
)
; break;
case
0x04:
read_pipe_block
(
chan_LS2Conf_LS4_genotype,
&fl_tmp
)
; break;
case
0x05:
read_pipe_block
(
chan_LS2Conf_LS5_genotype,
&fl_tmp
)
; break;
case
0x06:
read_pipe_block
(
chan_LS2Conf_LS6_genotype,
&fl_tmp
)
; break;
case
0x07:
read_pipe_block
(
chan_LS2Conf_LS7_genotype,
&fl_tmp
)
; break;
case
0x08:
read_pipe_block
(
chan_LS2Conf_LS8_genotype,
&fl_tmp
)
; break;
case
0x09:
read_pipe_block
(
chan_LS2Conf_LS9_genotype,
&fl_tmp
)
; break;
}
if
(
i
>
2
)
{
...
...
ofdock_taskpar_xl/device/Krnl_GA.cl
View file @
1ca1d501
This diff is collapsed.
Click to expand it.
ofdock_taskpar_xl/device/Krnl_IGL_SimplifArbiter.cl
View file @
1ca1d501
...
...
@@ -37,125 +37,37 @@ void Krnl_IGL_Arbiter(/*unsigned char DockConst_num_of_genes*/
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_IGL_MAIN:
while
(
active
)
{
nb_pipe_status
Off_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
IC_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
GG_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS1_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS2_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS3_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS4_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS5_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS6_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS7_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS8_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
LS9_end_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
Off_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
IC_valid
=
PIPE_STATUS_FAILURE
;
nb_pipe_status
GG_valid
=
PIPE_STATUS_FAILURE
;
int
Off_active
;
int
IC_active
;
int
GG_active
;
int
LS1_end_active
;
int
LS2_end_active
;
int
LS3_end_active
;
int
LS4_end_active
;
int
LS5_end_active
;
int
LS6_end_active
;
int
LS7_end_active
;
int
LS8_end_active
;
int
LS9_end_active
;
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_IGL_INNER:
while
(
(
Off_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
IC_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
GG_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS1_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS2_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS3_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS4_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS5_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS6_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS7_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS8_end_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
LS9_end_valid
!=
PIPE_STATUS_SUCCESS
)
(
GG_valid
!=
PIPE_STATUS_SUCCESS
)
)
{
Off_valid
=
read_pipe
(
chan_IGLArbiter_Off,
&Off_active
)
;
IC_valid
=
read_pipe
(
chan_GA2IGL_IC_active,
&IC_active
)
;
GG_valid
=
read_pipe
(
chan_GA2IGL_GG_active,
&GG_active
)
;
LS1_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS1_end,
&LS1_end_active
)
;
LS2_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS2_end,
&LS2_end_active
)
;
LS3_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS3_end,
&LS3_end_active
)
;
LS4_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS4_end,
&LS4_end_active
)
;
LS5_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS5_end,
&LS5_end_active
)
;
LS6_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS6_end,
&LS6_end_active
)
;
LS7_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS7_end,
&LS7_end_active
)
;
LS8_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS8_end,
&LS8_end_active
)
;
LS9_end_valid
=
read_pipe
(
chan_LS2Arbiter_LS9_end,
&LS9_end_active
)
;
}
active
=
(
Off_valid
==
PIPE_STATUS_SUCCESS
)
?
0x00
:
0x01
;
bool
mode_LS_bool
[9]
;
__attribute__
((
opencl_unroll_hint
))
LOOP_FOR_IGL_INIT_MODE_LS_BOOL:
for
(
uchar
i=0
; i<9; i++) {
mode_LS_bool
[i]
=
false
;
}
//
Determine
"mode_LS_bool"
value
//
This
considers
all
possible
cases
as
all
LS
could
be
//
potentially
producing
genotypes
simultaneously.
if
(
active
==
0x01
)
{
if
((
IC_valid
!=
PIPE_STATUS_SUCCESS
)
&&
(
GG_valid
!=
PIPE_STATUS_SUCCESS
))
{
if
(
LS1_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[0]
=
true
; /*printf("LS1 valid!\n");*/}
if
(
LS2_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[1]
=
true
; /*printf("LS2 valid!\n");*/}
if
(
LS3_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[2]
=
true
; /*printf("LS3 valid!\n");*/}
if
(
LS4_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[3]
=
true
; /*printf("LS4 valid!\n");*/}
if
(
LS5_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[4]
=
true
; /*printf("LS5 valid!\n");*/}
if
(
LS6_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[5]
=
true
; /*printf("LS6 valid!\n");*/}
if
(
LS7_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[6]
=
true
; /*printf("LS7 valid!\n");*/}
if
(
LS8_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[7]
=
true
; /*printf("LS8 valid!\n");*/}
if
(
LS9_end_valid
==
PIPE_STATUS_SUCCESS
)
{mode_LS_bool
[8]
=
true
; /*printf("LS9 valid!\n");*/}
}
}
//
End
if
(
active
==
0x01
)
//
Send
"mode"
to
Conform
__attribute__
((
xcl_pipeline_loop
))
LOOP_FOR_IGL_WRITE_MODE:
for
(
uchar
j=0
; j<9; j++) {
bool
enable_write_channel
=
false
;
char
mode_tmp
;
const
char
mode_Off
=
0x00
;
const
char
mode_IC
=
'I
'
;
const
char
mode_GG
=
'G
'
;
const
char
mode_LS
[9]
=
{0x01,
0x02,
0x03,
0x04,
0x05,
0x06,
0x07,
0x08,
0x09}
;
if
(
Off_valid
==
PIPE_STATUS_SUCCESS
)
{
enable_write_channel
=
(
j==0
)
?
true:false
;
mode_tmp
=
mode_Off
;
}
else
if
(
IC_valid
==
PIPE_STATUS_SUCCESS
)
{
enable_write_channel
=
(
j==0
)
?
true:false
;
mode_tmp
=
mode_IC
;
}
else
if
(
GG_valid
==
PIPE_STATUS_SUCCESS
)
{
enable_write_channel
=
(
j==0
)
?
true:false
;
mode_tmp
=
mode_GG
;
}
else{
if
(
mode_LS_bool[j]
==
true
)
{
enable_write_channel
=
true
;
mode_tmp
=
mode_LS
[j]
;
}
}
const
char
mode_Off
=
0x00
;
const
char
mode_IC
=
'I
'
;
const
char
mode_GG
=
'G
'
;
if
(
enable_write_channel
==
true
)
{
write_pipe_block
(
chan_IGL2Conform_actmode,
&mode_tmp
)
;
}
}
//
End
for
(
uchar
j=0
; j<9; j++)
char
mode_tmp
=
(
Off_valid
==
PIPE_STATUS_SUCCESS
)
?
mode_Off
:
(
IC_valid
==
PIPE_STATUS_SUCCESS
)
?
mode_IC
:
mode_GG
;
write_pipe_block
(
chan_IGL2Conform_actmode,
&mode_tmp
)
;
//printf
(
"IGL Simplif sent!\n"
)
;
}
//
End
of
while
(
active
)
}
...
...
ofdock_taskpar_xl/device/Krnl_InterE.cl
View file @
1ca1d501
...
...
@@ -292,15 +292,6 @@ while(active) {
switch
(
mode
)
{
case
'I
'
:
write_pipe_block
(
chan_Intere2StoreIC_intere,
&final_interE
)
; break;
case
'G
'
:
write_pipe_block
(
chan_Intere2StoreGG_intere,
&final_interE
)
; break;
case
0x01:
write_pipe_block
(
chan_Intere2StoreLS_LS1_intere,
&final_interE
)
; break;
case
0x02:
write_pipe_block
(
chan_Intere2StoreLS_LS2_intere,
&final_interE
)
; break;
case
0x03:
write_pipe_block
(
chan_Intere2StoreLS_LS3_intere,
&final_interE
)
; break;
case
0x04:
write_pipe_block
(
chan_Intere2StoreLS_LS4_intere,
&final_interE
)
; break;
case
0x05:
write_pipe_block
(
chan_Intere2StoreLS_LS5_intere,
&final_interE
)
; break;
case
0x06:
write_pipe_block
(
chan_Intere2StoreLS_LS6_intere,
&final_interE
)
; break;
case
0x07:
write_pipe_block
(
chan_Intere2StoreLS_LS7_intere,
&final_interE
)
; break;
case
0x08:
write_pipe_block
(
chan_Intere2StoreLS_LS8_intere,
&final_interE
)
; break;
case
0x09:
write_pipe_block
(
chan_Intere2StoreLS_LS9_intere,
&final_interE
)
; break;
}
//
--------------------------------------------------------------
...
...
ofdock_taskpar_xl/device/Krnl_IntraE.cl
View file @
1ca1d501
...
...
@@ -239,15 +239,6 @@ while(active) {
switch
(
mode
)
{
case
'I
'
:
write_pipe_block
(
chan_Intrae2StoreIC_intrae,
&intraE
)
; break;
case
'G
'
:
write_pipe_block
(
chan_Intrae2StoreGG_intrae,
&intraE
)
; break;
case
0x01:
write_pipe_block
(
chan_Intrae2StoreLS_LS1_intrae,
&intraE
)
; break;
case
0x02:
write_pipe_block
(
chan_Intrae2StoreLS_LS2_intrae,
&intraE
)
; break;
case
0x03:
write_pipe_block
(
chan_Intrae2StoreLS_LS3_intrae,
&intraE
)
; break;
case
0x04:
write_pipe_block
(
chan_Intrae2StoreLS_LS4_intrae,
&intraE
)
; break;
case
0x05:
write_pipe_block
(
chan_Intrae2StoreLS_LS5_intrae,
&intraE
)
; break;
case
0x06:
write_pipe_block
(
chan_Intrae2StoreLS_LS6_intrae,
&intraE
)
; break;
case
0x07:
write_pipe_block
(
chan_Intrae2StoreLS_LS7_intrae,
&intraE
)
; break;
case
0x08:
write_pipe_block
(
chan_Intrae2StoreLS_LS8_intrae,
&intraE
)
; break;
case
0x09:
write_pipe_block
(
chan_Intrae2StoreLS_LS9_intrae,
&intraE
)
; break;
}
//
--------------------------------------------------------------
...
...
ofdock_taskpar_xl/device/Krnl_LS.cl
deleted
100644 → 0
View file @
db054c9a
//
--------------------------------------------------------------------------
//
--------------------------------------------------------------------------
__kernel
__attribute__
((
reqd_work_group_size
(
1
,
1
,
1
)))
void
Krnl_LS
(
unsigned
short
DockConst_max_num_of_iters,
float
DockConst_rho_lower_bound,
float
DockConst_base_dmov_mul_sqrt3,
unsigned
char
DockConst_num_of_genes,
float
DockConst_base_dang_mul_sqrt3,
unsigned
char
DockConst_cons_limit
#
if
!defined
(
SW_EMU
)
//
IMPORTANT:
enable
this
dummy
global
argument
only
for
"hw"
build.
//
Check
..
/common_xilinx/utility/boards.mk
//
https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
,
__global
int
*dummy
#
endif
)
{
#
if
0
printf
(
"\nLS: DockConst_max_num_of_iters: %u\n"
,
DockConst_max_num_of_iters
)
;
printf
(
"LS: DockConst_rho_lower_bound: %f\n"
,
DockConst_rho_lower_bound
)
;
printf
(
"LS: DockConst_base_dmov_mul_sqrt3: %f\n"
,
DockConst_base_dmov_mul_sqrt3
)
;
printf
(
"LS: DockConst_num_of_genes: %u\n"
,
DockConst_num_of_genes
)
;
printf
(
"LS: DockConst_base_dang_mul_sqrt3: %f\n"
,
DockConst_base_dang_mul_sqrt3
)
;
printf
(
"LS: DockConst_cons_limit: %u\n"
,
DockConst_cons_limit
)
;
#
endif
/*bool
valid
=
true
;*/
char
valid
=
0x01
;
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_LS_MAIN:
while
(
valid
)
{
/*int
active
;*/
int
active
=
0
;
nb_pipe_status
valid_active
=
PIPE_STATUS_FAILURE
;
float
current_energy
;
nb_pipe_status
valid_energy
=
PIPE_STATUS_FAILURE
;
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_LS_ACTIVE:
while
(
(
valid_active
!=
PIPE_STATUS_SUCCESS
)
&&
(
valid_energy
!=
PIPE_STATUS_SUCCESS
))
{
valid_active
=
read_pipe
(
chan_GA2LS_Off1_active,
&active
)
;
valid_energy
=
read_pipe
(
chan_GA2LS_LS1_energy,
¤t_energy
)
;
}
//
(
active
==
1
)
means
stop
LS
/*valid
=
(
active
!=
1
)
|
| (valid_energy == PIPE_STATUS_SUCCESS);*/
/*valid = ! ((valid_active == PIPE_STATUS_SUCCESS) && (active == 1)) || (valid_energy == PIPE_STATUS_SUCCESS);*/
// Received something on pipe: chan_GA2LS_Off_active?
// If so, then turn this kernel off
valid = (valid_active == PIPE_STATUS_SUCCESS)? 0x00:0x01;
if (valid) {
float genotype [ACTUAL_GENOTYPE_LENGTH];
__attribute__((xcl_pipeline_loop))
LOOP_FOR_LS_READ_INPUT_GENOTYPE:
for (uchar i=0; i<DockConst_num_of_genes; i++) {
read_pipe_block(chan_GA2LS_LS1_genotype, &genotype [i]);
}
float rho = 1.0f;
ushort iteration_cnt = 0;
uchar cons_succ = 0;
uchar cons_fail = 0;
uint LS_eval = 0;
bool positive_direction = true;
// performing local search
__attribute__((xcl_pipeline_loop))
LOOP_WHILE_LS_ITERATION_RHO:
while ((iteration_cnt < DockConst_max_num_of_iters) && (rho > DockConst_rho_lower_bound)) {
// -----------------------------------------------
// Exit condition is groups here. It allows pipelining
if (positive_direction == true) {
if (cons_succ >= DockConst_cons_limit) {
rho = LS_EXP_FACTOR*rho;
cons_fail = 0;
cons_succ = 0;
}
else if (cons_fail >= DockConst_cons_limit) {
rho = LS_CONT_FACTOR*rho;
cons_fail = 0;
cons_succ = 0;
}
iteration_cnt++;
}
#if defined (DEBUG_KRNL_LS1)
printf("LS1 positive?: %u, iteration_cnt: %u, rho: %f, limit rho: %f\n", positive_direction, iteration_cnt, rho, DockConst_rho_lower_bound);
#endif
// -----------------------------------------------
float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH];
float genotype_bias [ACTUAL_GENOTYPE_LENGTH];
float deviate_plus_bias [ACTUAL_GENOTYPE_LENGTH];
float deviate_minus_bias [ACTUAL_GENOTYPE_LENGTH];
// Tell Krnl_Conf_Arbiter, LS1 is done
// Not completely strict as the (iteration_cnt < DockConst_max_num_of_iters) is ignored
// In practice, rho condition dominates most of the cases
int tmp_int = (rho < DockConst_rho_lower_bound)?0:1;
write_pipe_block(chan_LS2Arbiter_LS1_end, &tmp_int);
/*
mem_fence(CLK_CHANNEL_MEM_FENCE);
*/
// new random deviate
// rho is the deviation of the uniform distribution
__attribute__((xcl_pipeline_loop))
LOOP_FOR_LS_WRITE_GENOTYPE:
for (uchar i=0; i<DockConst_num_of_genes; i++) {
float tmp_prng;
read_pipe_block(chan_PRNG2LS_float_prng, &tmp_prng);
/*
mem_fence(CLK_CHANNEL_MEM_FENCE);
*/
// tmp1 is genotype_deviate
float tmp1 = rho * (2.0f*tmp_prng - 1.0f);
if (i<3) { tmp1 = tmp1 * DockConst_base_dmov_mul_sqrt3; }
else { tmp1 = tmp1 * DockConst_base_dang_mul_sqrt3; }
float deviate = 0.4f*tmp1;
// tmp2 is the addition: genotype_deviate + genotype_bias
// tmp3 is entity_possible_new_genotype
float tmp_bias = (iteration_cnt == 1)? 0.0f:genotype_bias[i];
float bias = 0.6f * tmp_bias;
deviate_plus_bias [i] = deviate + bias;
deviate_minus_bias [i] = deviate - bias;
float tmp2 = tmp1 + tmp_bias;
float tmp3 = (positive_direction == true)? (genotype [i] + tmp2): (genotype [i] - tmp2);
if (i>2) {if (i==4) { tmp3 = map_angle_180(tmp3); }
else { tmp3 = map_angle_360(tmp3); }}
entity_possible_new_genotype [i] = tmp3;
write_pipe_block(chan_LS2Conf_LS1_genotype, &tmp3);
#if defined (DEBUG_KRNL_LS1)
printf("LS1_genotype sent\n");
#endif
}
//printf("Energy to calculate sent from LS ... ");
float energyIA_LS_rx;
float energyIE_LS_rx;
nb_pipe_status intra_valid = PIPE_STATUS_FAILURE;
nb_pipe_status inter_valid = PIPE_STATUS_FAILURE;
__attribute__((xcl_pipeline_loop))
LOOP_WHILE_LS_READ_ENERGIES:
while( (intra_valid != PIPE_STATUS_SUCCESS) |
|
(
inter_valid
!=
PIPE_STATUS_SUCCESS
)
)
{
if
(
intra_valid
!=
PIPE_STATUS_SUCCESS
)
{
intra_valid
=
read_pipe
(
chan_Intrae2StoreLS_LS1_intrae,
&energyIA_LS_rx
)
;
}
else
if
(
inter_valid
!=
PIPE_STATUS_SUCCESS
)
{
inter_valid
=
read_pipe
(
chan_Intere2StoreLS_LS1_intere,
&energyIE_LS_rx
)
;
}
}
float
candidate_energy
=
energyIA_LS_rx
+
energyIE_LS_rx
;
//
update
LS
energy-evaluation
count
LS_eval++
;
if
(
candidate_energy
<
current_energy
)
{
//
updating
offspring_genotype
//
updating
genotype_bias
__attribute__
((
xcl_pipeline_loop
))
LOOP_FOR_LS_FLOATPT_UPDATE_POS_GENOTYPE:
for
(
uchar
i=0
; i<DockConst_num_of_genes; i++) {
genotype_bias
[i]
=
(
positive_direction
==
true
)
?
deviate_plus_bias
[i]
:
deviate_minus_bias
[i]
;
genotype
[i]
=
entity_possible_new_genotype
[i]
;
}
current_energy
=
candidate_energy
;
cons_succ++
;
cons_fail
=
0
;
positive_direction
=
true
;
}
else
{
//
updating
(
halving
)
genotype_bias
__attribute__
((
xcl_pipeline_loop
))
LOOP_FOR_LS_FLOATPT_UPDATE_NEG_GENOTYPE:
for
(
uchar
i=0
; i<DockConst_num_of_genes; i++) {
genotype_bias
[i]
=
(
iteration_cnt
==
1
)
?
0.0f:
(
0.5f*genotype_bias
[i]
)
;
}
if
(
positive_direction
==
false
)
{
cons_fail++
;
cons_succ
=
0
;
}
positive_direction
=
!positive_direction
;
}
}
//
end
of
while
(
iteration_cnt
)
&&
(
rho
)
#
if
defined
(
DEBUG_KRNL_LS1
)
printf
(
"Out of while iter LS1\n"
)
;
#
endif
//
write
back
data
to
GA
__attribute__
((
xcl_pipeline_loop
))
LOOP_FOR_LS_WRITEBACK2GA:
for
(
uchar
i=0
; i<DockConst_num_of_genes; i++) {
if
(
i
==
0
)
{
float2
evalenergy
=
{*
(
float*
)
&LS_eval,
current_energy}
;
write_pipe_block
(
chan_LS2GA_LS1_evalenergy,
&evalenergy
)
;
}
/*
mem_fence
(
CLK_CHANNEL_MEM_FENCE
)
;
*/
write_pipe_block
(
chan_LS2GA_LS1_genotype,
&genotype
[i]
)
;
}
}
//
End
of
if
(
valid
)
}
//
End
of
while
(
valid
)
#
if
defined
(
DEBUG_ACTIVE_KERNEL
)
printf
(
" %-20s: %s\n"
,
"Krnl_LS1"
,
"disabled"
)
;
#
endif
}
//
--------------------------------------------------------------------------
//
--------------------------------------------------------------------------
ofdock_taskpar_xl/device/Krnl_LS2.cl
deleted
100644 → 0
View file @
db054c9a
//
--------------------------------------------------------------------------
//
--------------------------------------------------------------------------
__kernel
__attribute__
((
reqd_work_group_size
(
1
,
1
,
1
)))
void
Krnl_LS2
(
unsigned
short
DockConst_max_num_of_iters,
float
DockConst_rho_lower_bound,
float
DockConst_base_dmov_mul_sqrt3,
unsigned
char
DockConst_num_of_genes,
float
DockConst_base_dang_mul_sqrt3,
unsigned
char
DockConst_cons_limit
#
if
!defined
(
SW_EMU
)
//
IMPORTANT:
enable
this
dummy
global
argument
only
for
"hw"
build.
//
Check
..
/common_xilinx/utility/boards.mk
//
https://forums.xilinx.com/t5/SDAccel/ERROR-KernelCheck-83-114-in-sdx-2017-4/td-p/818135
,
__global
int
*dummy
#
endif
)
{
#
if
0
printf
(
"\nLS2: DockConst_max_num_of_iters: %u\n"
,
DockConst_max_num_of_iters
)
;
printf
(
"LS2: DockConst_rho_lower_bound: %f\n"
,
DockConst_rho_lower_bound
)
;
printf
(
"LS2: DockConst_base_dmov_mul_sqrt3: %f\n"
,
DockConst_base_dmov_mul_sqrt3
)
;
printf
(
"LS2: DockConst_num_of_genes: %u\n"
,
DockConst_num_of_genes
)
;
printf
(
"LS2: DockConst_base_dang_mul_sqrt3: %f\n"
,
DockConst_base_dang_mul_sqrt3
)
;
printf
(
"LS2: DockConst_cons_limit: %u\n"
,
DockConst_cons_limit
)
;
#
endif
/*bool
valid
=
true
;*/
char
valid
=
0x01
;
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_LS2_MAIN:
while
(
valid
)
{
int
active
;
nb_pipe_status
valid_active
=
PIPE_STATUS_FAILURE
;
float
current_energy
;
nb_pipe_status
valid_energy
=
PIPE_STATUS_FAILURE
;
__attribute__
((
xcl_pipeline_loop
))
LOOP_WHILE_LS2_ACTIVE:
while
(
(
valid_active
!=
PIPE_STATUS_SUCCESS
)
&&
(
valid_energy
!=
PIPE_STATUS_SUCCESS
))
{
valid_active
=
read_pipe
(
chan_GA2LS_Off2_active,
&active
)
;
valid_energy
=
read_pipe
(
chan_GA2LS_LS2_energy,
¤t_energy
)
;
}
//
(
active
==
1
)
means
stop
LS
/*valid
=
(
active
!=
1
)
|
| (valid_energy == PIPE_STATUS_SUCCESS);*/
// Received something on pipe: chan_GA2LS_Off_active?
// If so, then turn this kernel off
valid = (valid_active == PIPE_STATUS_SUCCESS)? 0x00:0x01;
if (valid) {
float genotype [ACTUAL_GENOTYPE_LENGTH];
__attribute__((xcl_pipeline_loop))
LOOP_FOR_LS2_READ_INPUT_GENOTYPE:
for (uchar i=0; i<DockConst_num_of_genes; i++) {
read_pipe_block(chan_GA2LS_LS2_genotype, &genotype [i]);
}
#if defined (DEBUG_KRNL_LS2)
printf("In of while iter LS2\n");
#endif
float rho = 1.0f;
ushort iteration_cnt = 0;
uchar cons_succ = 0;
uchar cons_fail = 0;
uint LS_eval = 0;
bool positive_direction = true;
// performing local search
__attribute__((xcl_pipeline_loop))
LOOP_WHILE_LS2_ITERATION_RHO:
while ((iteration_cnt < DockConst_max_num_of_iters) && (rho > DockConst_rho_lower_bound)) {
// -----------------------------------------------
// Exit condition is groups here. It allows pipelining
if (positive_direction == true) {
if (cons_succ >= DockConst_cons_limit) {
rho = LS_EXP_FACTOR*rho;
cons_fail = 0;
cons_succ = 0;
}
else if (cons_fail >= DockConst_cons_limit) {
rho = LS_CONT_FACTOR*rho;
cons_fail = 0;
cons_succ = 0;
}
iteration_cnt++;
}
#if defined (DEBUG_KRNL_LS2)
printf("LS2 positive?: %u, iteration_cnt: %u, rho: %f, limit rho: %f\n", positive_direction, iteration_cnt, rho, DockConst_rho_lower_bound);
#endif
// -----------------------------------------------
float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH];
float genotype_bias [ACTUAL_GENOTYPE_LENGTH];
float deviate_plus_bias [ACTUAL_GENOTYPE_LENGTH];
float deviate_minus_bias [ACTUAL_GENOTYPE_LENGTH];
// Tell Krnl_Conf_Arbiter, LS2 is done
// Not completely strict as the (iteration_cnt < DockConst_max_num_of_iters) is ignored
// In practice, rho condition dominates most of the cases
int tmp_int = (rho < DockConst_rho_lower_bound)?0:1;