Skip to content

Commit 790527a

Browse files
committed
Clean up runtime code for simulation preprogram autodiscovery string load
Newest simulation runtime allows the autodiscovery string to be read from the same address as in hardware, therefore, this change removes special handling for the simulation flow in the kernel interface initialization.
1 parent 9f87503 commit 790527a

13 files changed

+145
-432
lines changed

include/acl_hal_mmd.h

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,112 @@
1010

1111
//////////////////////////////////////////////////////////////////////////
1212
// //
13-
// Implementation of HAL that builds on top of aocl_mmd (board vendor //
13+
// Versioning constants, address maps, and bit/byte positionings used //
14+
// in acl_kernel_if and acl_pll //
15+
// //
16+
//////////////////////////////////////////////////////////////////////////
17+
18+
//// acl_kernel_if
19+
// Versioning: This value must be read from addr 0
20+
// For unit tests to work, this defines must match the one in the unit test
21+
// header file
22+
#define KERNEL_VERSION_ID (0xa0c00001)
23+
#define KERNEL_ROM_VERSION_ID (0xa0c00002)
24+
// Version number in the top 16-bits of the 32-bit status register. Used
25+
// to verify that the hardware and HAL have an identical view of the CSR
26+
// address map.
27+
#define CSR_VERSION_ID_18_1 (3)
28+
#define CSR_VERSION_ID_19_1 (4)
29+
#define CSR_VERSION_ID_23_1 (5)
30+
#define CSR_VERSION_ID CSR_VERSION_ID_23_1
31+
32+
// Address map
33+
// For unit tests to work, these defines must match those in the unit test
34+
// header file
35+
#define OFFSET_KERNEL_VERSION_ID ((dev_addr_t)0x0000)
36+
#define OFFSET_KERNEL_CRA_SEGMENT ((dev_addr_t)0x0020)
37+
#define OFFSET_SW_RESET ((dev_addr_t)0x0030)
38+
#define OFFSET_KERNEL_CRA ((dev_addr_t)0x1000)
39+
#define OFFSET_CONFIGURATION_ROM ((dev_addr_t)0x2000)
40+
41+
// Addressses for Kernel System ROM
42+
#define OFFSET_KERNEL_ROM_LOCATION_MSB (0x3ffffff8)
43+
#define OFFSET_KERNEL_ROM_LOCATION_LSB (0x3ffffffc)
44+
#define OFFSET_KERNEL_MAX_ADDRESS (0x3fffffff)
45+
46+
#define KERNEL_CRA_SEGMENT_SIZE (0x1000)
47+
#define KERNEL_ROM_SIZE_BYTES_READ 4
48+
#define KERNEL_ROM_SIZE_BYTES 8
49+
50+
// Byte offsets into the CRA:
51+
// For CSR version >= 5 byte offsets are pushed back with the proper
52+
// value except for the CSR later on in the runtime execution
53+
#define KERNEL_OFFSET_CSR 0
54+
#define KERNEL_OFFSET_PRINTF_BUFFER_SIZE 0x4
55+
#define KERNEL_OFFSET_CSR_PROFILE_CTRL 0xC
56+
#define KERNEL_OFFSET_CSR_PROFILE_DATA 0x10
57+
#define KERNEL_OFFSET_CSR_PROFILE_START_CYCLE 0x18
58+
#define KERNEL_OFFSET_CSR_PROFILE_STOP_CYCLE 0x20
59+
#define KERNEL_OFFSET_FINISH_COUNTER 0x28
60+
#define KERNEL_OFFSET_INVOCATION_IMAGE 0x30
61+
62+
// CSR version >= 5 byte offsets
63+
#define KERNEL_OFFSET_START_REG 0x8
64+
65+
// Backwards compatibility with CSR_VERSION_ID 3
66+
#define KERNEL_OFFSET_INVOCATION_IMAGE_181 0x28
67+
68+
// Bit positions
69+
#define KERNEL_CSR_START 0
70+
#define KERNEL_CSR_DONE 1
71+
#define KERNEL_CSR_STALLED 3
72+
#define KERNEL_CSR_UNSTALL 4
73+
#define KERNEL_CSR_PROFILE_TEMPORAL_STATUS 5
74+
#define KERNEL_CSR_PROFILE_TEMPORAL_RESET 6
75+
#define KERNEL_CSR_LAST_STATUS_BIT KERNEL_CSR_PROFILE_TEMPORAL_RESET
76+
#define KERNEL_CSR_STATUS_BITS_MASK \
77+
((unsigned)((1 << (KERNEL_CSR_LAST_STATUS_BIT + 1)) - 1))
78+
#define KERNEL_CSR_LMEM_INVALID_BANK 11
79+
#define KERNEL_CSR_LSU_ACTIVE 12
80+
#define KERNEL_CSR_WR_ACTIVE 13
81+
#define KERNEL_CSR_BUSY 14
82+
#define KERNEL_CSR_RUNNING 15
83+
#define KERNEL_CSR_FIRST_VERSION_BIT 16
84+
#define KERNEL_CSR_LAST_VERSION_BIT 31
85+
86+
#define KERNEL_CSR_PROFILE_SHIFT64_BIT 0
87+
#define KERNEL_CSR_PROFILE_RESET_BIT 1
88+
#define KERNEL_CSR_PROFILE_ALLOW_PROFILING_BIT 2
89+
#define KERNEL_CSR_PROFILE_LOAD_BUFFER_BIT 3
90+
#define KERNEL_CSR_PROFILE_SHARED_CONTROL_BIT1 4
91+
#define KERNEL_CSR_PROFILE_SHARED_CONTROL_BIT2 5
92+
93+
#define CONFIGURATION_ROM_BYTES 4096
94+
95+
#define RESET_TIMEOUT (2 * 1000 * 1000 * 1000)
96+
97+
//// acl_pll
98+
// Address map
99+
// For unit tests to work, these defines must match those in the unit test
100+
// header file
101+
#define OFFSET_PLL_VERSION_ID ((dev_addr_t)0x000)
102+
#define OFFSET_ROM ((dev_addr_t)0x400)
103+
#define OFFSET_RECONFIG_CTRL ((dev_addr_t)0x200)
104+
#define OFFSET_RECONFIG_CTRL_20NM ((dev_addr_t)0x800)
105+
#define OFFSET_COUNTER ((dev_addr_t)0x100)
106+
#define OFFSET_RESET ((dev_addr_t)0x110)
107+
#define OFFSET_LOCK ((dev_addr_t)0x120)
108+
109+
// Constants
110+
#define MAX_KNOWN_SETTINGS 100
111+
#define MAX_POSSIBLE_FMAX 2000000
112+
#define MAX_RECONFIG_RETRIES 3
113+
#define RECONFIG_TIMEOUT (1000000000ll)
114+
#define CLK_MEASUREMENT_PERIOD (16 * 1024 * 1024)
115+
116+
//////////////////////////////////////////////////////////////////////////
117+
// //
118+
// Implementation of HAL that builds on top of aocl_mmd (board vendor //
14119
// visible), acl_pll, and acl_kernel_if. //
15120
// //
16121
//////////////////////////////////////////////////////////////////////////

include/acl_mem.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ int acl_submit_mem_transfer_device_op(cl_event event);
3232

3333
int acl_submit_migrate_mem_device_op(cl_event event);
3434

35-
int acl_realloc_buffer_for_simulator(cl_mem mem,
36-
const unsigned int physical_device_id,
37-
const unsigned int mem_id);
38-
3935
// Actually execute the memory transfer device operation.
4036
// In the normal case source and destination are different, in which case
4137
// the HAL is called and the transfer is non-blocking.

src/acl_globals.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const char *acl_get_offline_device_user_setting(int *use_offline_only_ret) {
7979
const char *setting_deprecated = 0;
8080
const char *result = 0;
8181
static char warn_depr1 = 0;
82-
static char warn_depr3 = 0;
8382

8483
setting = acl_getenv("CL_CONTEXT_OFFLINE_DEVICE_INTELFPGA");
8584
setting_deprecated = acl_getenv("CL_CONTEXT_OFFLINE_DEVICE_ALTERA");

src/acl_hostch.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ static cl_int l_push_packet(unsigned int physical_device_id, int channel_handle,
4141
// Pushed data can be smaller than the request write_size due to compiler
4242
// padding. Runtime needs to check if the trailing bytes are all 0s.
4343
else if ((pushed_data > 0) && (pushed_data < write_size)) {
44-
for (int i = pushed_data; i < write_size; i++) {
44+
for (size_t i = pushed_data; i < write_size; i++) {
4545
unsigned char c = ((char *)host_buffer)[i];
4646
if (c != 0) {
4747
// This shouldn't happen. Needs to send out a warning to user rather
4848
// than a silent function failure.
4949
std::cerr << "Error: Data is not fully written into the Hostpipe. "
5050
"None-0 bits have been cut off \n";
51-
return CL_INVALID_VALUE;
51+
assert(0);
5252
}
5353
}
5454
return CL_SUCCESS;
@@ -825,7 +825,6 @@ void acl_write_program_hostpipe(void *user_data, acl_device_op_t *op) {
825825

826826
cl_int status;
827827
cl_event event = op->info.event;
828-
cl_context context = event->context;
829828
bool blocking = event->cmd.info.host_pipe_info.blocking;
830829
acl_assert_locked();
831830

src/acl_kernel.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,12 +2918,6 @@ static cl_int l_copy_and_adjust_arguments_for_device(
29182918
[needed_mem_id]);
29192919
#endif
29202920

2921-
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM) {
2922-
if (!acl_realloc_buffer_for_simulator(mem_obj, needed_physical_id,
2923-
needed_mem_id)) {
2924-
return CL_MEM_OBJECT_ALLOCATION_FAILURE;
2925-
}
2926-
}
29272921
// copy the address of the reserved allocation into the invocation
29282922
// image:
29292923
const void *mem_addr =

0 commit comments

Comments
 (0)