Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types for device properties and state only available within that devices handlers #232

Closed
m8pple opened this issue Jun 12, 2021 · 4 comments · Fixed by #276
Closed

Types for device properties and state only available within that devices handlers #232

m8pple opened this issue Jun 12, 2021 · 4 comments · Fixed by #276
Assignees
Labels
bug Report of a bug composer Issues related to the Composer softswitch Issues related to the Softswitch

Comments

@m8pple
Copy link
Contributor

m8pple commented Jun 12, 2021

This follows on from #231.

This was done on development_dt10_branch (fd0196a), as otherwise I
cant get through parsing through to compilation. The branch has the current 1.0.0-alpha merged in.

Some existing graphs refer to various global types in order to work out things like the maximum
size of things at compile-time. Also, within the global SharedCode it might refer to any of the
state or properties of devices.

At the moment it looks like only the types for the device currently being compiled are emitted, which breaks
applications that use multiple device types and refer to those types from across handlers.

For example, this is used in an APSP implementation to statically work out batch size:

https://github.com/POETSII/poets_improvement_proposals/blob/2a355282f3aa3912bdacf4ec50bf25199bdf310d/proposed/PIP-0020/xml/ic/apps/apsp_vec_barrier_150_10.xml#L12-L15

Current behaviour:

dt10@joxer:~/POETS/Orchestrator$ ./orchestrate.sh 
[WARN] Launcher: Not running on a POETS box, and found no motherships running on alternative machines, so we're not spawning any mothership processes.
POETS> 12:32:49.03:  20(I) The microlog for the command 'load /engine = "../Config/POETSHardwareOneBox.ocfg"' will be written to '../Output/Microlog/Microlog_2021_06_12T12_32_49p0.plog'.
POETS> 12:32:49.03: 140(I) Topology loaded from file ||../Config/POETSHardwareOneBox.ocfg||.
POETS>load /app = "/home/dt10/POETS/Orchestrator/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml"
Msg: share = '// Line 43
uint32_t source;
uint32_t distances[8];
'
Msg: stats = '// Line 49
uint64_t sum_sum_distance;
uint32_t vertex_count;
uint32_t max_distances[8];
'
POETS> 12:32:51.05:  23(I) load /app = "/home/dt10/POETS/Orchestrator/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml"
POETS> 12:32:51.05:  20(I) The microlog for the command 'load /app = "/home/dt10/POETS/Orchestrator/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml"' will be written to '../Output/Microlog/Microlog_2021_06_12T12_32_51p0.plog'.
POETS> 12:32:51.05: 235(I) Application file /home/dt10/POETS/Orchestrator/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml loading...
POETS> 12:32:51.05:  65(I) Application file /home/dt10/POETS/Orchestrator/Tests/ReferenceXML/v4/PEP20/apps/apsp_vec_barrier_150_10.xml loaded in 2054 ms.
POETS>tlink /app = *
POETS> 12:32:54.75:  23(I) tlink /app = *
POETS> 12:32:54.75:  20(I) The microlog for the command 'tlink /app = *' will be written to '../Output/Microlog/Microlog_2021_06_12T12_32_54p0.plog'.
POETS>place /tfill = *
POETS> 12:32:56.99:  23(I) place /tfill = *
POETS> 12:32:56.99:  20(I) The microlog for the command 'place /tfill = *' will be written to '../Output/Microlog/Microlog_2021_06_12T12_32_56p0.plog'.
POETS> 12:32:56.99: 309(I) Attempting to place graph instance 'apsp_150_10' using the 'tfil' method...
POETS> 12:32:56.99: 302(I) Graph instance 'apsp_150_10' placed successfully.
POETS>compose /app = *
POETS> 12:33:06.35:  23(I) compose /app = *
POETS> 12:33:06.35:  20(I) The microlog for the command 'compose /app = *' will be written to '../Output/Microlog/Microlog_2021_06_12T12_32_58p0.plog'.
POETS> 12:33:06.35: 803(I) Composing graph instance 'apsp_150_10'...
POETS> 12:33:06.35: 806(W) Graph instance 'apsp_150_10' compose failed. Check the microlog for details.
POETS>

Microlog:

========================================================================================================================
12/06/2021 12:32:58.32 file ../Output/Microlog/Microlog_2021_06_12T12_32_58p0.plog
command [compose /app = *]
from console
========================================================================================================================


Composing apsp_150_10...
	Generating Supervisor...	Done!
	Generating code for 2 cores
	Core 0: Files... Source... 
	Core 32: Files... Source... 
RTS Buffer for thread 0 expanded from 1 to 10

	Make called with make -j$(nproc --ignore=4) all SOFTSWITCH_TRIVIAL_LOG_HANDLER=1 SOFTSWITCH_LOGLEVEL=2 > make_errs.txt 2>&1
Compilation failed! make_errs.txt dump ++++++++++++++++++++++++++++++++++++++++

riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o softswitch.o /home/dt10/POETS/Orchestrator/Source/Softswitch/src/softswitch.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o vars_0_0.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/vars_0_0.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o io.o /home/dt10/POETS/Orchestrator/Tinsel/lib/io.c
riscv32-unknown-elf-gcc -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o entry.o /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/entry.S
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o softswitch_main.o /home/dt10/POETS/Orchestrator/Source/Softswitch/src/softswitch_main.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o softswitch_common.o /home/dt10/POETS/Orchestrator/Source/Softswitch/src/softswitch_common.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o vars_0.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/vars_0.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o handlers_0.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_0.cpp
/home/dt10/POETS/Orchestrator/Source/Softswitch/src/genld.sh 0 > link_0.ld
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o vars_32_0.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/vars_32_0.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o vars_32.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/vars_32.cpp
riscv32-unknown-elf-g++ -mabi=ilp32 -march=rv32imf -static -mcmodel=medany -fvisibility=hidden -nostartfiles -pipe -fsingle-precision-constant -fno-builtin-printf -ffp-contract=off -std=c++14 -Wall -O2  -DTRIVIAL_LOG_HANDLER -DP_LOG_LEVEL=2 -I /home/dt10/POETS/Orchestrator/Tinsel/include -I /home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc -I/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated -I /home/dt10/POETS/Orchestrator/Generics -I /home/dt10/POETS/Orchestrator/Source/Common -Wall -c -o handlers_32.o /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_0.cpp: In instantiation of 'void begin_round(const GP*, const DP*, DS*) [with GP = apsp_vec_barrier_properties_t; DP = vertex_properties_t; DS = vertex_state_t]':
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_0.cpp:100:63:   required from here
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_0.cpp:52:35: warning: comparison of integer expressions of different signedness: 'int32_t' {aka 'long int'} and 'unsigned int' [-Wsign-compare]
      if(0 <= id_delta && id_delta < K){
                          ~~~~~~~~~^~~
/home/dt10/POETS/Orchestrator/Source/Softswitch/src/genld.sh 32 > link_32.ld
cp /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/supervisor.bin ./
ld -r -b binary -o SupervisorData.o supervisor.bin
rm supervisor.bin
riscv32-unknown-elf-ld -melf32lriscv -G 0 -L/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/lib/rv32im/ilp32 -L/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/lib/gcc/riscv32-unknown-elf/8.2.0/rv32im/ilp32 -lgcc -lc -T link_0.ld -o ../bin/softswitch_0.elf softswitch_main.o softswitch_common.o softswitch.o vars_0.o vars_0_0.o handlers_0.o io.o entry.o /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/lib/rv32im/ilp32/libc.a /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/lib/gcc/riscv32-unknown-elf/8.2.0/rv32im/ilp32/libgcc.a
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/mpich/bin/mpicxx -I/home/dt10/POETS/Orchestrator/Source/Softswitch/inc -I/home/dt10/POETS/Orchestrator/Tinsel/include -I/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/mpich/include -I/home/dt10/POETS/Orchestrator/Source/Common -I/home/dt10/POETS/Orchestrator/Generics  -std=c++14 -fPIC -pipe -Wall -shared -L/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/mpich/lib -O3 -Wl,-soname,libSupervisor.so -o ../bin/libSupervisor.so /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/Supervisor.cpp SupervisorData.o
/home/dt10/POETS/Orchestrator/Tinsel/bin/checkelf.sh ../bin/softswitch_0.elf
riscv32-unknown-elf-objcopy -O verilog --only-section=.text ../bin/softswitch_0.elf ../bin/softswitch_code_0.v
riscv32-unknown-elf-objcopy -O verilog --remove-section=.text --set-section-flags .bss=alloc,load,contents ../bin/softswitch_0.elf ../bin/softswitch_data_0.v
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:46: error: 'apsp_vec_barrier_vertex_state_t' was not declared in this scope
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:46: note: suggested alternative: 'apsp_vec_barrier_collector_state_t'
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                              apsp_vec_barrier_collector_state_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:79: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                               ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:79: error: template argument 1 is invalid
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                               ^
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:114: error: 'apsp_vec_barrier_vertex_state_t' was not declared in this scope
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:114: note: suggested alternative: 'apsp_vec_barrier_collector_state_t'
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                  apsp_vec_barrier_collector_state_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:147: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                                                                                                   ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:25:147: error: template argument 1 is invalid
   const unsigned K_STATE=sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances) / sizeof(std::declval<apsp_vec_barrier_vertex_state_t>().distances[0]);
                                                                                                                                                   ^
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:70: error: 'apsp_vec_barrier_vertex_properties_t' was not declared in this scope
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:70: note: suggested alternative: 'apsp_vec_barrier_collector_properties_t'
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                      apsp_vec_barrier_collector_properties_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:108: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                            ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:108: error: template argument 1 is invalid
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                            ^
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:159: error: 'apsp_vec_barrier_vertex_properties_t' was not declared in this scope
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:159: note: suggested alternative: 'apsp_vec_barrier_collector_properties_t'
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                                                               apsp_vec_barrier_collector_properties_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:197: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                                                                                                                     ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:29:197: error: template argument 1 is invalid
   const unsigned num_debug_1st_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_1st_round_distances[0]);
                                                                                                                                                                                                     ^
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:70: error: 'apsp_vec_barrier_vertex_properties_t' was not declared in this scope
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:70: note: suggested alternative: 'apsp_vec_barrier_collector_properties_t'
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                      apsp_vec_barrier_collector_properties_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:108: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                            ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:108: error: template argument 1 is invalid
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                            ^
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:159: error: 'apsp_vec_barrier_vertex_properties_t' was not declared in this scope
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:159: note: suggested alternative: 'apsp_vec_barrier_collector_properties_t'
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                                                               apsp_vec_barrier_collector_properties_t
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:197: error: no matching function for call to 'declval<<expression error> >()'
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                                                                                                                     ^
In file included from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/move.h:55,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_pair.h:59,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/stl_algobase.h:64,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/bits/char_traits.h:39,
                 from /mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/string:40,
                 from /home/dt10/POETS/Orchestrator/Generics/OSFixes.hpp:3,
                 from /home/dt10/POETS/Orchestrator/Source/Common/poets_pkt.h:7,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch.h:4,
                 from /home/dt10/POETS/Orchestrator/Source/Softswitch/inc/softswitch_common.h:4,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/vars_32.h:19,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/inc/handlers_32.h:18,
                 from /home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:16:
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note: candidate: 'template<class _Tp> decltype (__declval<_Tp>(0)) std::declval()'
     auto declval() noexcept -> decltype(__declval<_Tp>(0))
          ^~~~~~~
/mnt/e/dt10_all/POETS/orchestrator_dependencies_7/riscv32-compile-driver/riscv32-unknown-elf/include/c++/8.2.0/type_traits:2056:10: note:   template argument deduction/substitution failed:
/home/dt10/POETS/Orchestrator/Output/Composer/apsp_150_10__apsp_150_10/Generated/src/handlers_32.cpp:30:197: error: template argument 1 is invalid
   const unsigned num_debug_2nd_round_distances = sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances) / sizeof(std::declval<apsp_vec_barrier_vertex_properties_t>().debug_2nd_round_distances[0]);
                                                                                                                                                                                                     ^
Makefile:192: recipe for target 'handlers_32.o' failed
make: *** [handlers_32.o] Error 1
rm softswitch_main.o softswitch_common.o vars_32.o vars_0.o link_32.ld handlers_0.o link_0.ld

Compilation failed! make_errs.txt dump ----------------------------------------

@mvousden
Copy link
Contributor

Perhaps I'm misunderstanding, but could one just define a type in the Graphs/GraphType/SharedCode element, and refer to the type from here? You could then define an instance of that type in your relevant CDATA section?

@heliosfa
Copy link
Contributor

Perhaps I'm misunderstanding, but could one just define a type in the Graphs/GraphType/SharedCode element, and refer to the type from here? You could then define an instance of that type in your relevant CDATA section?

You used to have to do this in our "v2" Softswitch for the local device shared code and it was a pain.

When we (you @DrongoTheDog and I) were discussing struct scoping, we decided that it made sense to make the device-level structs available in the device's shared code but that making them available at the global level could cause issues. Unfortunately I can't remember what the issues we identified were, but compile time springs to mind.

Also, within the global SharedCode it might refer to any of the state or properties of devices.

Is this just for sizing? or are there other "legitimate" reasons you can see for devices (and by extension supervisors) to have access to the struct declarations for all device types?

I guess that a potential fix is to emit a general types header (rather than just a message types header) that includes all of the extra structs. However, where does this stop? Does it include all of the edge props/state structs as well?

@m8pple
Copy link
Contributor Author

m8pple commented Jun 14, 2021

Yes, you could create a custom type in Graphs/GraphType/SharedCode, but that type would be completely
independent of the types used for things like messages, states, and properties.

You could replicate the structure of a message type, and then make sure you kept the
two definitions in sync, but that is a recipe for problems, as experience suggests that
the widths of types get changes slightly or someone inserts another variable, but
then forget to update them.

There is also a worry that an implementation might decide to lay out the types
differently in memory - for example, some part compiled in gcc-x86 and some part
compiled in risc-v, which relies on implementation-defined padding and packing
decisions. That's why it is required that all structs are emitted with #pragma pack(1),
as otherwise it is impossible to move the around portably.

(I notice that the orchestrator doesn't emit pragma pack 1. I guess this is less of
an issue while externals are not supported, but does suggest some quite interesting
edge cases between the Mothership and the devices...)

Also, if you take the approach of having two distinct types you need to either memcpy
between the two (wasting time), or type-pun them via pointers, which means the
handlers become non-synthesisable in HLS. (A HLS POETS implementation existed in the
past, and may exist again in the future).

So the well-known type-name is there to allow handlers to refer to the types
as emitted by the implementation, as it avoids a lot of those problems. Note
that there is also the cTypeName override, though I haven't looked into
whether the orchestrator supports that.

You could then define an instance of that type in your relevant CDATA section?

I assume by CDATA section you mean something like a MessageType or State element?
That approach will work with an implementation that does not introspect types and
views them as strings (such as the orchestrator), but many other implementations
parse and introspect all types and values in order to discover errors, and to enable
direct binary generation (rather than getting gcc to do it).

In the v3 XML there was more support for custom type instances through typedefs,
but that was seen as too complicated to implement, so was removed in v4. So in
v4 the only things allows in the typedDataSpec and typedDataValue fields must
be standalone, with the only allowable types coming from cstdint:

https://github.com/POETSII/poets_improvement_proposals/blob/2a355282f3aa3912bdacf4ec50bf25199bdf310d/proposed/PIP-0020/virtual-graph-schema-v4.rnc#L847-L880

@m8pple
Copy link
Contributor Author

m8pple commented Jun 14, 2021

When we (you @DrongoTheDog and I) were discussing struct scoping, we decided that it made sense to make the device-level structs available in the device's shared code but that making them available at the global level could cause issues. Unfortunately I can't remember what the issues we identified were, but compile time springs to mind.

It's done in various other implementations (at least two simulators in graph_schema, poets_eco_system, and the reference
parser/implementation developed during the PIP20 discussions.

When exposed as global type names, you get {graphTypeId}_{deviceTypeId}_properties_t, so it shouldn't be
possible for them to conflict. Within each handler there are supposed to be aliases DEVICE_STATE_T and
DEVICE_PROPERTIES_T, but those are local to each handler (it appears unspecified whether they are in
scope for the SharedCode section of a device - I think they were intended to be, but it is a little
implicit).

Is this just for sizing? or are there other "legitimate" reasons you can see for devices (and by extension supervisors) to have access to the struct declarations for all device types?

It's mainly todo with sizing, and for things like static assertions. It's useful to check at compile-time
that the parameters associated with one handler are still compatible with the current configuration
of another parameter.

It was more useful with the V3 support for typedefs, but a few of those use-cases have disappeared
with the simplification for V4.

In cases where you are working around the lack of expressiveness, it is still useful to be able to
static_assert that your type-punning is actually valid. For example, if a particular struct is being
serialised in a raw byte message (to get around lack of unions and typedefs), it is useful to
check that the size of the struct being sent is the same as the expected one being received.

I guess that a potential fix is to emit a general types header (rather than just a message types header) that includes all of the extra structs. However, where does this stop? Does it include all of the edge props/state structs as well?

Yes, the spec expects named types for edge properties and state too:

https://github.com/POETSII/poets_improvement_proposals/blob/2a355282f3aa3912bdacf4ec50bf25199bdf310d/proposed/PIP-0020/virtual-graph-schema-v4.rnc#L434

https://github.com/POETSII/poets_improvement_proposals/blob/2a355282f3aa3912bdacf4ec50bf25199bdf310d/proposed/PIP-0020/virtual-graph-schema-v4.rnc#L445

@heliosfa heliosfa self-assigned this Jun 14, 2021
@heliosfa heliosfa added bug Report of a bug composer Issues related to the Composer softswitch Issues related to the Softswitch labels Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of a bug composer Issues related to the Composer softswitch Issues related to the Softswitch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants