1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
|
/* messages.h - message types for PoCL-Remote communication
Copyright (c) 2018 Michal Babej / Tampere University of Technology
Copyright (c) 2019-2023 Jan Solanti / Tampere University
Copyright (c) 2023-2024 Pekka Jääskeläinen / Intel Finland Oy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
#include "pocl.h"
#include "pocl_remote.h"
#ifndef POCL_REMOTE_MESSAGES_H
#define POCL_REMOTE_MESSAGES_H
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __GNUC__
#pragma GCC visibility push(hidden)
#endif
/* ########################## */
#define DEFAULT_QUE_ID (1UL << 24)
#define ENUM_TYPE uint8_t
#define MAX_PACKED_STRING_LEN 1024
#define AUTHKEY_LENGTH 16
#define STRING_TYPE(x) char x[MAX_PACKED_STRING_LEN]
#define WRITEV_REQ(num, SIZE) writev_req (data, vecs, num, SIZE)
#define CHECK_REPLY(type) \
if (!netcmd->reply.failed) \
assert (netcmd->reply.message_type == MessageType_##type##Reply); \
assert (netcmd->reply.did == ddata->remote_device_index); \
assert (netcmd->reply.pid == ddata->remote_platform_index); \
if (netcmd->reply.failed) \
{ \
POCL_MSG_ERR ("Reply is FAIL: %i\n", netcmd->reply.fail_details); \
return netcmd->reply.fail_details; \
}
#define READ_DATA(ptr, size) read_data (data, ptr, size)
#include <stddef.h>
#include <stdint.h>
typedef struct vec3_s
{
uint64_t x;
uint64_t y;
uint64_t z;
} vec3_t;
typedef enum DevType
{
CPU = 1,
GPU,
ACCELERATOR,
CUSTOM
} DevType;
#define MAX_IMAGE_FORMAT_TYPES 1024
enum RequestMessageType
{
MessageType_InvalidRequest,
MessageType_CreateOrAttachSession,
MessageType_ServerInfo,
MessageType_DeviceInfo,
MessageType_ConnectPeer,
MessageType_PeerHandshake,
MessageType_CreateBuffer,
MessageType_FreeBuffer,
MessageType_CreateCommandQueue,
MessageType_FreeCommandQueue,
MessageType_CreateSampler,
MessageType_FreeSampler,
MessageType_CreateImage,
MessageType_FreeImage,
MessageType_CreateKernel,
MessageType_FreeKernel,
MessageType_BuildProgramFromSource,
MessageType_BuildProgramFromBinary,
MessageType_BuildProgramWithBuiltins,
MessageType_BuildProgramWithDefinedBuiltins,
// Special message type for SPIR-V IL for now. No support for
// vendor-specific ILs.
MessageType_BuildProgramFromSPIRV,
MessageType_CompileProgramFromSPIRV,
MessageType_CompileProgramFromSource,
MessageType_LinkProgram,
MessageType_FreeProgram,
MessageType_CreateCommandBuffer,
MessageType_FreeCommandBuffer,
// ***********************************************
MessageType_MigrateD2D,
MessageType_Barrier,
MessageType_ReadBuffer,
MessageType_WriteBuffer,
MessageType_CopyBuffer,
MessageType_FillBuffer,
MessageType_ReadBufferRect,
MessageType_WriteBufferRect,
MessageType_CopyBufferRect,
MessageType_CopyImage2Buffer,
MessageType_CopyBuffer2Image,
MessageType_CopyImage2Image,
MessageType_ReadImageRect,
MessageType_WriteImageRect,
MessageType_FillImageRect,
MessageType_RunKernel,
MessageType_RunCommandBuffer,
MessageType_NotifyEvent,
MessageType_RdmaBufferRegistration,
// TODO finish
MessageType_Finish,
MessageType_Shutdown,
};
enum ReplyMessageType
{
MessageType_InvalidReply,
MessageType_CreateOrAttachSessionReply,
MessageType_ServerInfoReply,
MessageType_DeviceInfoReply,
MessageType_ConnectPeerReply,
MessageType_PeerHandshakeReply,
MessageType_CreateBufferReply,
MessageType_FreeBufferReply,
MessageType_CreateCommandQueueReply,
MessageType_FreeCommandQueueReply,
MessageType_CreateSamplerReply,
MessageType_FreeSamplerReply,
MessageType_CreateImageReply,
MessageType_FreeImageReply,
MessageType_CreateKernelReply,
MessageType_FreeKernelReply,
MessageType_BuildProgramReply,
MessageType_FreeProgramReply,
MessageType_CreateCommandBufferReply,
MessageType_FreeCommandBufferReply,
// ***********************************************
MessageType_MigrateD2DReply,
MessageType_ReadBufferReply,
MessageType_WriteBufferReply,
MessageType_CopyBufferReply,
MessageType_FillBufferReply,
MessageType_CopyImage2BufferReply,
MessageType_CopyBuffer2ImageReply,
MessageType_CopyImage2ImageReply,
MessageType_ReadImageRectReply,
MessageType_WriteImageRectReply,
MessageType_FillImageRectReply,
MessageType_RunKernelReply,
MessageType_RunCommandBufferReply,
MessageType_Failure
};
typedef struct __attribute__ ((packed)) ImgFormatType_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t channel_order;
uint32_t channel_data_type;
} ImgFormatType_t;
typedef struct __attribute__ ((packed)) ImgFormatInfo_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t memobj_type;
uint32_t num_formats;
ImgFormatType_t formats[MAX_IMAGE_FORMAT_TYPES];
} ImgFormatInfo_t;
typedef struct __attribute__ ((packed))
CreateOrAttachSessionMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t peer_id;
uint16_t peer_port;
uint8_t use_rdma;
uint8_t fast_socket;
} CreateOrAttachSessionMsg_t;
typedef struct __attribute__ ((packed))
CreateOrAttachSessionReply_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t session;
uint8_t authkey[AUTHKEY_LENGTH];
uint16_t peer_port;
uint8_t use_rdma;
} CreateOrAttachSessionReply_t;
typedef struct __attribute__ ((packed)) DeviceInfo_s
{
/* ######## device properties ############## */
/* Offsets to the strings-section. */
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t name;
uint64_t opencl_c_version;
uint64_t device_version;
uint64_t driver_version;
uint64_t vendor;
uint64_t extensions;
uint64_t builtin_kernels;
uint64_t supported_spir_v_versions;
uint64_t on_host_queue_props;
uint64_t cmdbuf_capabilities;
uint64_t cmdbuf_required_properties;
uint64_t cmdbuf_supported_properties;
uint32_t vendor_id;
// uint32_t device_id;
uint32_t address_bits;
uint32_t mem_base_addr_align;
uint32_t global_mem_cache_size;
uint32_t global_mem_cache_type;
uint64_t global_mem_size;
uint32_t global_mem_cacheline_size;
/* The starting address of a region from which coarse grain SVM
allocations should be made. */
uint64_t svm_pool_start_address;
/* And the size of it. Set to 0 in case CG SVM is not supported
by the remote device. */
uint64_t svm_pool_size;
uint64_t double_fp_config;
uint64_t single_fp_config;
uint64_t half_fp_config;
uint32_t local_mem_size;
uint32_t local_mem_type;
uint32_t max_clock_frequency;
uint32_t max_compute_units;
uint32_t max_constant_args;
uint64_t max_constant_buffer_size;
uint64_t max_mem_alloc_size;
uint32_t max_parameter_size;
uint32_t max_read_image_args;
uint32_t max_write_image_args;
uint32_t max_samplers;
uint32_t max_work_item_dimensions;
uint64_t max_work_group_size;
uint64_t max_work_item_size_x;
uint64_t max_work_item_size_y;
uint64_t max_work_item_size_z;
/* ############ CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE DEPRECATED */
uint32_t native_vector_width_char;
uint32_t native_vector_width_short;
uint32_t native_vector_width_int;
uint32_t native_vector_width_long;
uint32_t native_vector_width_float;
uint32_t native_vector_width_double;
uint32_t native_vector_width_half;
uint32_t preferred_vector_width_char;
uint32_t preferred_vector_width_short;
uint32_t preferred_vector_width_int;
uint32_t preferred_vector_width_long;
uint32_t preferred_vector_width_float;
uint32_t preferred_vector_width_double;
uint32_t preferred_vector_width_half;
/* ############# SUBDEVICES - later */
uint32_t printf_buffer_size;
uint32_t profiling_timer_resolution;
/* ########### images */
uint32_t image2d_max_height;
uint32_t image2d_max_width;
uint32_t image3d_max_height;
uint32_t image3d_max_width;
uint32_t image3d_max_depth;
uint64_t image_max_buffer_size;
uint64_t image_max_array_size;
/* ########### subgroups */
uint32_t max_num_sub_groups;
ENUM_TYPE type;
uint8_t available;
uint8_t compiler_available;
uint8_t endian_little;
uint8_t error_correction_support;
uint8_t image_support;
uint8_t full_profile;
cl_bool host_unified_memory;
ImgFormatInfo_t supported_image_formats[6];
/* If a single (vendor-specific) device info is queried (instead
of all the basic device info data all at once), its data
will be stored in this union verbatim. */
union
{
/* E.g. for CL_DEVICE_SUB_GROUP_SIZES_INTEL. */
size_t size_t_array[16];
cl_uint uint_val;
cl_bool bool_val;
cl_device_feature_capabilities_intel intel_capab_val;
} specific_info_data;
/* The size of the value is returned in specificInfoSize. Zero
is used to signal an unknown/unsupported key type. */
uint32_t specific_info_size;
} DeviceInfo_t;
typedef struct __attribute__ ((packed)) ConnectPeerMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint16_t port;
uint64_t session;
uint8_t authkey[AUTHKEY_LENGTH];
char address[MAX_REMOTE_PARAM_LENGTH + 1];
} ConnectPeerMsg_t;
/* ########################## */
/* ########################## */
/* ########################## */
/* ########################## */
/* ########################## */
/* ########################## */
typedef struct __attribute__ ((packed)) MigrateD2DMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t size;
uint32_t source_pid;
uint32_t source_did;
uint32_t size_id;
uint32_t dest_peer_id;
uint32_t source_peer_id;
uint32_t is_image;
uint32_t is_external;
uint32_t width;
uint32_t height;
uint32_t depth;
} MigrateD2DMsg_t;
typedef struct __attribute__ ((packed)) CreateBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t size;
uint32_t flags;
/* If non-zero, a previously allocated SVM pointer to be wrapped as
the backing store for the buffer OR a pointer to a host-side
backing store. Should set to CL_MEM_USES_SVM_POINTER to flags,
if the former. */
uint64_t host_ptr;
/* Parent buffer id, if this is a sub-buffer allocation request. */
pocl_obj_id_t parent_id;
/* The offset inside the parent buffer, if this is a sub-buffer. */
uint64_t origin;
} CreateBufferMsg_t;
typedef struct __attribute__ ((packed)) CreateBufferReply_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t device_addr;
} CreateBufferReply_t;
#ifdef ENABLE_RDMA
typedef struct __attribute__ ((packed)) CreateRdmaBufferReply_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t server_vaddr;
uint32_t server_rkey;
} CreateRdmaBufferReply_t;
#endif
typedef struct __attribute__ ((packed)) FreeBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t padding;
/* If set to 1, the id of the buffer is the device side SVM allocation
address to free, otherwise a cl_mem id.*/
unsigned char is_svm;
} FreeBufferMsg_t;
typedef struct __attribute__ ((packed)) ReadBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t src_offset;
uint64_t size;
uint64_t content_size;
pocl_obj_id_t content_size_id;
#ifdef ENABLE_RDMA
uint64_t client_vaddr;
uint32_t client_rkey;
#endif
/* If set to 1, the buffer to be written is an SVM buffer, not a cl_mem
one. In that case, the obj_id of the request is set to the raw svm pool
offset adjusted (remote VM) pointer instead of a cl_mem object id. */
unsigned char is_svm;
} ReadBufferMsg_t;
typedef struct __attribute__ ((packed)) WriteBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t dst_offset;
uint64_t size;
uint64_t content_size;
/* If set to 1, the buffer to be written is an SVM buffer, not a cl_mem
one. In that case, the obj_id of the request is set to the raw svm pool
offset adjusted (remote VM) pointer instead of a cl_mem object id. */
unsigned char is_svm;
} WriteBufferMsg_t;
typedef struct __attribute__ ((packed)) CopyBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t src_buffer_id;
uint32_t dst_buffer_id;
uint32_t size_buffer_id;
uint64_t src_offset;
uint64_t dst_offset;
uint64_t size;
} CopyBufferMsg_t;
typedef struct __attribute__ ((packed)) FillBufferMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t dst_offset;
uint64_t size;
uint64_t pattern_size;
} FillBufferMsg_t;
typedef struct __attribute__ ((packed)) ReadBufferRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t buffer_origin;
vec3_t region;
uint64_t buffer_row_pitch;
uint64_t buffer_slice_pitch;
uint64_t host_bytes;
#ifdef ENABLE_RDMA
uint64_t client_vaddr;
uint32_t client_rkey;
#endif
} ReadBufferRectMsg_t;
typedef struct __attribute__ ((packed)) WriteBufferRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t buffer_origin;
vec3_t region;
uint64_t buffer_row_pitch;
uint64_t buffer_slice_pitch;
uint64_t host_bytes;
} WriteBufferRectMsg_t;
typedef struct __attribute__ ((packed)) CopyBufferRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t src_buffer_id;
uint32_t dst_buffer_id;
vec3_t dst_origin;
vec3_t src_origin;
vec3_t region;
uint64_t dst_row_pitch;
uint64_t dst_slice_pitch;
uint64_t src_row_pitch;
uint64_t src_slice_pitch;
} CopyBufferRectMsg_t;
typedef struct __attribute__ ((packed)) CreateImageMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t flags;
// format
uint32_t channel_order;
uint32_t channel_data_type;
// desc
uint32_t type;
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t array_size;
uint32_t row_pitch;
uint32_t slice_pitch;
// cl_uint num_mip_levels;
// cl_uint num_samples;
} CreateImageMsg_t;
typedef struct __attribute__ ((packed)) CreateSamplerMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t normalized;
uint32_t address_mode;
uint32_t filter_mode;
} CreateSamplerMsg_t;
typedef struct __attribute__ ((packed)) CopyImage2ImageMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t src_image_id;
uint32_t dst_image_id;
vec3_t dst_origin;
vec3_t src_origin;
vec3_t region;
} CopyImg2ImgMsg_t;
typedef struct __attribute__ ((packed)) CopyBuf2ImgMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t origin;
vec3_t region;
uint32_t src_buf_id;
uint64_t src_offset;
} CopyBuf2ImgMsg_t;
typedef struct __attribute__ ((packed)) CopyImg2BufMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t origin;
vec3_t region;
uint32_t dst_buf_id;
uint64_t dst_offset;
} CopyImg2BufMsg_t;
typedef struct __attribute__ ((packed)) ReadImageRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t origin;
vec3_t region;
uint64_t host_bytes;
#ifdef ENABLE_RDMA
uint64_t client_vaddr;
uint32_t client_rkey;
#endif
} ReadImageRectMsg_t;
typedef struct __attribute__ ((packed)) WriteImageRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t origin;
vec3_t region;
uint64_t host_bytes;
} WriteImageRectMsg_t;
typedef struct __attribute__ ((packed)) FillImageRectMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t origin;
vec3_t region;
} FillImageRectMsg_t;
typedef struct __attribute__ ((packed)) BuildProgramMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t payload_size;
uint64_t options_len;
// nonzero, if the program's memory accesses should be offset-adjusted
// to match the SVM region starts in the remote device and the host
uint64_t svm_region_offset;
uint32_t num_devices;
uint32_t devices[MAX_REMOTE_DEVICES];
uint32_t platforms[MAX_REMOTE_DEVICES];
// program: char*
// options: char*
} BuildProgramMsg_t;
typedef struct __attribute__ ((packed)) CreateKernelMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t name_len;
uint32_t prog_id;
} CreateKernelMsg_t;
typedef struct __attribute__ ((packed)) FreeKernelMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint32_t prog_id;
} FreeKernelMsg_t;
typedef struct __attribute__ ((packed)) RunKernelMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
vec3_t global;
vec3_t local;
vec3_t offset;
uint8_t has_local;
uint8_t dim;
// if new args are present
uint16_t has_new_args;
uint32_t args_num;
uint64_t pod_arg_size;
} RunKernelMsg_t;
typedef struct __attribute__ ((packed)) DeviceInfoMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
/* If non-zero, the client has requested a specific device info
instead of all standard ones at once. */
cl_device_info id;
} DeviceInfoMsg_t;
typedef struct __attribute__ ((packed, aligned (8))) CreateCommandBufferMsg_s
{
uint64_t num_queues;
uint64_t queues_offset;
uint64_t num_commands;
uint64_t commands_offset;
uint64_t commands_size;
} CreateCommandBufferMsg_t;
/* ########################## */
typedef struct __attribute__ ((packed)) PeerHandshake_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t peer_id;
} PeerHandshake_t;
/* ########################## */
typedef struct __attribute__ ((packed)) RequestMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t session;
uint8_t authkey[AUTHKEY_LENGTH];
uint64_t msg_id;
uint64_t event_id;
uint32_t pid;
uint32_t did;
uint32_t client_did;
uint32_t waitlist_size;
uint32_t message_type;
uint64_t obj_id;
uint32_t cq_id;
union
{
CreateOrAttachSessionMsg_t get_session;
ConnectPeerMsg_t connect_peer;
PeerHandshake_t peer_handshake;
CreateBufferMsg_t create_buffer;
CreateSamplerMsg_t create_sampler;
CreateImageMsg_t create_image;
FreeBufferMsg_t free_buffer;
MigrateD2DMsg_t migrate;
ReadBufferMsg_t read;
WriteBufferMsg_t write;
CopyBufferMsg_t copy;
FillBufferMsg_t fill_buffer;
ReadBufferRectMsg_t read_rect;
WriteBufferRectMsg_t write_rect;
CopyBufferRectMsg_t copy_rect;
CopyImg2ImgMsg_t copy_img2img;
CopyBuf2ImgMsg_t copy_buf2img;
CopyImg2BufMsg_t copy_img2buf;
FillImageRectMsg_t fill_image;
ReadImageRectMsg_t read_image_rect;
WriteImageRectMsg_t write_image_rect;
BuildProgramMsg_t build_program;
CreateKernelMsg_t create_kernel;
FreeKernelMsg_t free_kernel;
RunKernelMsg_t run_kernel;
DeviceInfoMsg_t device_info;
CreateCommandBufferMsg_t create_cmdbuf;
} m;
} RequestMsg_t;
/* #################################################################### */
/* #################################################################### */
/* #################################################################### */
/* #################################################################### */
/* #################################################################### */
/* #################################################################### */
typedef enum PoclRemoteArgType
{
POD = 0,
Pointer,
Image,
Sampler,
Local
} PoclRemoteArgType;
typedef struct __attribute__ ((packed)) ArgumentInfo_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
STRING_TYPE (name);
STRING_TYPE (type_name);
uint32_t address_qualifier;
uint32_t access_qualifier;
uint32_t type_qualifier;
PoclRemoteArgType type;
// uint32_t type_size;
} ArgumentInfo_t;
/*
typedef struct pocl_kernel_metadata_s
{
cl_uint num_args;
cl_uint num_locals;
size_t *local_sizes;
char *name;
char *attributes;
struct pocl_argument_info *arg_info;
cl_bitfield has_arg_metadata;
size_t reqd_wg_size[OPENCL_MAX_DIMENSION];
void **data;
} pocl_kernel_metadata_t;
*/
typedef struct EventTiming_s
{
uint64_t queued;
uint64_t submitted;
uint64_t started;
uint64_t completed;
} EventTiming_t;
typedef struct __attribute__ ((packed)) KernelMetaInfo_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
STRING_TYPE (name);
STRING_TYPE (attributes);
vec3_t reqd_wg_size;
uint64_t total_local_size;
uint32_t num_args;
} KernelMetaInfo_t;
typedef struct __attribute__ ((packed)) ReplyMsg_s
{
POCL_ALIGNAS(8) // Meant for aligning the structure, not the members.
uint64_t msg_id;
// this is the Platform ID on remote side
uint32_t pid;
// this is the Device ID on remote side
uint32_t did;
// this is the Device ID on local (client) side
uint32_t client_did;
uint32_t message_type;
uint32_t failed;
int32_t fail_details;
uint64_t data_size;
/* This has to be 64b since freeBuffer() uses it for the SVM pointer. */
uint64_t obj_id;
/* If the reply has a dynamic pool of c-strings after the end of
the structure's fields, this is set to its size. */
/* The actual strings will be appended after the object as a sequence
of 0-terminated strings.*/
uint64_t strings_size;
// remote server timing data from libOpenCL
EventTiming_t timing;
// set by remote server
uint64_t server_read_start_timestamp_ns;
uint64_t server_read_end_timestamp_ns;
uint64_t server_write_start_timestamp_ns;
union
{
CreateOrAttachSessionReply_t get_session;
PeerHandshake_t peer_handshake;
CreateBufferReply_t create_buffer;
} m;
} ReplyMsg_t;
/* ########################## */
static inline size_t
request_size (uint32_t message_type)
{
size_t body;
switch (message_type)
{
case MessageType_CreateOrAttachSession:
body = sizeof (CreateOrAttachSessionMsg_t);
break;
case MessageType_ConnectPeer:
body = sizeof (ConnectPeerMsg_t);
break;
case MessageType_PeerHandshake:
body = sizeof (PeerHandshake_t);
break;
case MessageType_CreateBuffer:
body = sizeof (CreateBufferMsg_t);
break;
case MessageType_FreeBuffer:
body = sizeof (FreeBufferMsg_t);
break;
case MessageType_CreateSampler:
body = sizeof (CreateSamplerMsg_t);
break;
case MessageType_CreateImage:
body = sizeof (CreateImageMsg_t);
break;
case MessageType_CreateKernel:
body = sizeof (CreateKernelMsg_t);
break;
case MessageType_FreeKernel:
body = sizeof (FreeKernelMsg_t);
break;
case MessageType_BuildProgramFromSource:
case MessageType_BuildProgramFromBinary:
case MessageType_BuildProgramFromSPIRV:
case MessageType_CompileProgramFromSource:
case MessageType_CompileProgramFromSPIRV:
case MessageType_BuildProgramWithBuiltins:
case MessageType_BuildProgramWithDefinedBuiltins:
case MessageType_LinkProgram:
body = sizeof (BuildProgramMsg_t);
break;
case MessageType_CreateCommandBuffer:
body = sizeof (CreateCommandBufferMsg_t);
break;
case MessageType_MigrateD2D:
body = sizeof (MigrateD2DMsg_t);
break;
case MessageType_ReadBuffer:
body = sizeof (ReadBufferMsg_t);
break;
case MessageType_WriteBuffer:
body = sizeof (WriteBufferMsg_t);
break;
case MessageType_CopyBuffer:
body = sizeof (CopyBufferMsg_t);
break;
case MessageType_FillBuffer:
body = sizeof (FillBufferMsg_t);
break;
case MessageType_ReadBufferRect:
body = sizeof (ReadBufferRectMsg_t);
break;
case MessageType_WriteBufferRect:
body = sizeof (WriteBufferRectMsg_t);
break;
case MessageType_CopyBufferRect:
body = sizeof (CopyBufferRectMsg_t);
break;
case MessageType_CopyImage2Buffer:
body = sizeof (CopyImg2BufMsg_t);
break;
case MessageType_CopyBuffer2Image:
body = sizeof (CopyBuf2ImgMsg_t);
break;
case MessageType_CopyImage2Image:
body = sizeof (CopyImg2ImgMsg_t);
break;
case MessageType_ReadImageRect:
body = sizeof (ReadImageRectMsg_t);
break;
case MessageType_WriteImageRect:
body = sizeof (WriteImageRectMsg_t);
break;
case MessageType_FillImageRect:
body = sizeof (FillImageRectMsg_t);
break;
case MessageType_RunKernel:
body = sizeof (RunKernelMsg_t);
break;
case MessageType_DeviceInfo:
body = sizeof (DeviceInfoMsg_t);
break;
default:
body = 0;
break;
}
return offsetof (RequestMsg_t, m) + body;
}
#ifdef ENABLE_RDMA
static inline int
pocl_request_is_rdma (RequestMsg_t *req, int is_p2p)
{
switch ((enum RequestMessageType) (req->message_type))
{
case MessageType_WriteBuffer:
case MessageType_WriteBufferRect:
return 1;
break;
case MessageType_MigrateD2D:
// Migration from a device on the client is done using WriteBuffer
// so MigrateD2D only ever has RDMA data in the p2p context
return is_p2p ? 1 : 0;
break;
default:
return 0;
}
}
static inline int
pocl_request_has_rdma_reply (RequestMsg_t *rep)
{
switch ((enum RequestMessageType) (rep->message_type))
{
case MessageType_ReadBuffer:
return 1;
break;
default:
return 0;
}
}
#endif
#ifdef __GNUC__
#pragma GCC visibility pop
#endif
#ifdef __cplusplus
}
#endif
#endif
|