|
18 | 18 | extern dsfmt_t dsfmt[NPMax*slotOfP]; |
19 | 19 |
|
20 | 20 | /*** FPGA mode: Call SMC core */ |
21 | | -void smcFPGA(int NP, int slotOfAllP, float S, int itl_outer, int outer_idx, int itl_inner, float* state_in, float* ref_in, int* seed, float* obsrv_in, float* state_out, float* weightObj, max_group_t* engines){ |
| 21 | +void smcFPGA(int NP, int slotOfAllP, float S, int itl_outer, int outer_idx, int itl_inner, float* state_in, float* ref_in, int* seed, float* obsrv_in, float* state_out, float* weightObj, max_group_t* group){ |
22 | 22 |
|
| 23 | + max_engine_t *engines[NBoard]; |
23 | 24 | struct timeval tv1, tv2; |
24 | 25 | unsigned long long lmem_time, kernel_time, resampling_time; |
25 | 26 |
|
@@ -69,22 +70,34 @@ void smcFPGA(int NP, int slotOfAllP, float S, int itl_outer, int outer_idx, int |
69 | 70 | #if Use_DRAM==1 |
70 | 71 | // Copy states to LMEM |
71 | 72 | gettimeofday(&tv1, NULL); |
72 | | - Smc_write_run_group(engines,*actions_write); // for NBoard FPGAs |
| 73 | + for (int i=0; i<NBoard; i++){ |
| 74 | + engines[i] = max_lock_any(group); |
| 75 | + Smc_write_run(engines[i], actions_write[i]); |
| 76 | + max_unlock(engines[i]); |
| 77 | + } |
73 | 78 | gettimeofday(&tv2, NULL); |
74 | 79 | lmem_time = (tv2.tv_sec - tv1.tv_sec)*1000000 + (tv2.tv_usec - tv1.tv_usec); |
75 | 80 | printf("Copied data to LMEM in %lu us.\n", (long unsigned int)lmem_time); |
76 | 81 | #endif |
77 | 82 | // Invoke FPGA kernel |
78 | 83 | gettimeofday(&tv1, NULL); |
79 | | - Smc_run_group(engines,*actions); |
| 84 | + for (int i=0; i<NBoard; i++){ |
| 85 | + engines[i] = max_lock_any(group); |
| 86 | + Smc_run(engines[i], actions[i]); |
| 87 | + max_unlock(engines[i]); |
| 88 | + } |
80 | 89 | gettimeofday(&tv2, NULL); |
81 | 90 | kernel_time = (tv2.tv_sec - tv1.tv_sec)*1000000 + (tv2.tv_usec - tv1.tv_usec); |
82 | 91 | printf("FPGA kernel finished in %lu us.\n", (long unsigned int)kernel_time); |
83 | 92 | #if Use_DRAM==1 |
84 | 93 | // Copy states from LMEM |
85 | 94 | gettimeofday(&tv1, NULL); |
86 | | - Smc_read_run_group(engines,*actions_read); |
87 | | - Smc_read_w_run_group(engines,*actions_read_w); |
| 95 | + for (int i=0; i<NBoard; i++){ |
| 96 | + engines[i] = max_lock_any(group); |
| 97 | + Smc_read_run(engines[i], actions_read[i]); |
| 98 | + Smc_read_w_run(engines[i], actions_read_w[i]); |
| 99 | + max_unlock(engines[i]); |
| 100 | + } |
88 | 101 | gettimeofday(&tv2, NULL); |
89 | 102 | lmem_time = (tv2.tv_sec - tv1.tv_sec)*1000000 + (tv2.tv_usec - tv1.tv_usec); |
90 | 103 | printf("Copied data from LMEM in %lu us.\n", (long unsigned int)lmem_time); |
|
0 commit comments