Skip to content

Commit

Permalink
fix_pals
Browse files Browse the repository at this point in the history
  • Loading branch information
TApplencourt committed Feb 5, 2025
1 parent bde2900 commit 89f8a19
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 20 deletions.
1 change: 1 addition & 0 deletions utils/yaml_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def find_types_map(types, cast_type, map)
"size_t" => [false, 8, "ffi_type_pointer"],
"intptr_t" => [true, 8, "ffi_type_pointer"],
"uintptr_t" => [false, 8, "ffi_type_pointer"],
"_Bool" => [false, 4, "ffi_type_uint32"],
}

INT_SIGN_MAP = INT_TYPE_MAP.map { |k, v| [k, v[0]] }.to_h
Expand Down
1 change: 1 addition & 0 deletions ze/btx_zeinterval_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "xprof_utils.hpp"
#include <cstddef> // Bytes
typedef bool _Bool;
#include <metababel/metababel.h>
#include <optional>
#include <stdexcept>
Expand Down
7 changes: 7 additions & 0 deletions ze/gen_ze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def gen_struct_printer(namespace, types)
puts <<EOF
case ZES_STRUCTURE_TYPE_BASE_STATE:
break;
case ZES_STRUCTURE_TYPE_DEVICE_UUID:
break;
EOF
end
puts <<EOF
Expand Down Expand Up @@ -219,6 +221,11 @@ def gen_struct_printer(namespace, types)
puts <<EOF
_init_tracer();
EOF
if c.name == 'zeInit'
puts <<EOF
_init_tracer_dump();
EOF
end
end
common_block.call(c, provider, types)
if c.has_return_type?
Expand Down
5 changes: 3 additions & 2 deletions ze/headers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ diff -u4 -r --new-file include/layers/zel_tracing_register_cb.h modified_include
diff -u4 -r --new-file include/loader/ze_loader_api.h modified_include/loader/ze_loader_api.h
--- include/loader/ze_loader_api.h 2024-04-02 13:42:16.693493309 -0500
+++ modified_include/loader/ze_loader_api.h 2024-04-02 13:11:54.060768340 -0500
@@ -7,10 +7,12 @@
@@ -7,10 +7,13 @@
* @file ze_loader_api.cpp
*
*/
Expand All @@ -52,12 +52,13 @@ diff -u4 -r --new-file include/loader/ze_loader_api.h modified_include/loader/ze
+//#include "ze_loader_internal.h"
+//#include "loader/ze_loader.h"
+#include "../ze_api.h"
+#include <stdbool.h>
+#define HMODULE void *

#define TRACING_COMP_NAME "loader"

#if defined(__cplusplus)
@@ -54,27 +56,10 @@
@@ -54,27 +57,10 @@

///////////////////////////////////////////////////////////////////////////////
/// @brief Exported function for getting version
Expand Down
2 changes: 1 addition & 1 deletion ze/include/layers/zel_tracing_register_cb.h
Original file line number Diff line number Diff line change
Expand Up @@ -3251,4 +3251,4 @@ zelTracerResetAllCallbacks(zel_tracer_handle_t hTracer);
} // extern "C"
#endif

#endif // zel_tracing_register_cb_H
#endif // zel_tracing_register_cb_H
7 changes: 4 additions & 3 deletions ze/include/loader/ze_loader_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ zeLoaderInit();
/// - ::ZE_RESULT_SUCCESS
/// - ::ZE_RESULT_ERROR_UNINITIALIZED
ZE_DLLEXPORT ze_result_t ZE_APICALL
zelLoaderDriverCheck(ze_init_flags_t flags);

//zelLoaderDriverCheck(ze_init_flags_t flags);
zelLoaderDriverCheck(ze_init_flags_t flags, void *globalInitStored, void *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly);

///////////////////////////////////////////////////////////////////////////////
/// @brief Internal function for Setting the ddi tables for the Tracing Layer.
///
ZE_DLLEXPORT ze_result_t ZE_APICALL
//zelLoaderTracingLayerInit(std::atomic<ze_dditable_t *> &zeDdiTable, std::atomic<zet_dditable_t *> &zetDdiTable, std::atomic<zes_dditable_t *> &zesDdiTable);
zelLoaderTracingLayerInit(void *zeDdiTable, void *zetDdiTable, void *zesDdiTable);


Expand Down Expand Up @@ -77,4 +78,4 @@ zelLoaderTranslateHandleInternal(

#if defined(__cplusplus)
}
#endif
#endif
12 changes: 10 additions & 2 deletions ze/include/ze_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file ze_api.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZE_API_H
Expand Down Expand Up @@ -1443,7 +1443,7 @@ typedef struct _ze_device_properties_t
///< structure (i.e. contains stype and pNext).
ze_device_type_t type; ///< [out] generic device type
uint32_t vendorId; ///< [out] vendor id from PCI configuration
uint32_t deviceId; ///< [out] device id from PCI configuration
uint32_t deviceId; ///< [out] device id from PCI configuration.
///< Note, the device id uses little-endian format.
ze_device_property_flags_t flags; ///< [out] 0 (none) or a valid combination of ::ze_device_property_flag_t
uint32_t subdeviceId; ///< [out] sub-device id. Only valid if ::ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE
Expand Down Expand Up @@ -4697,6 +4697,9 @@ typedef enum _ze_image_format_layout_t
ZE_IMAGE_FORMAT_LAYOUT_444P = 40, ///< Media Format: 444P. Format type and swizzle is ignored for this.
ZE_IMAGE_FORMAT_LAYOUT_RGBP = 41, ///< Media Format: RGBP. Format type and swizzle is ignored for this.
ZE_IMAGE_FORMAT_LAYOUT_BRGP = 42, ///< Media Format: BRGP. Format type and swizzle is ignored for this.
ZE_IMAGE_FORMAT_LAYOUT_8_8_8 = 43, ///< 3-component 8-bit layout
ZE_IMAGE_FORMAT_LAYOUT_16_16_16 = 44, ///< 3-component 16-bit layout
ZE_IMAGE_FORMAT_LAYOUT_32_32_32 = 45, ///< 3-component 32-bit layout
ZE_IMAGE_FORMAT_LAYOUT_FORCE_UINT32 = 0x7fffffff

} ze_image_format_layout_t;
Expand Down Expand Up @@ -10545,6 +10548,9 @@ typedef enum _ze_image_bindless_exp_flag_t
{
ZE_IMAGE_BINDLESS_EXP_FLAG_BINDLESS = ZE_BIT(0), ///< Bindless images are created with ::zeImageCreate. The image handle
///< created with this flag is valid on both host and device.
ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE = ZE_BIT(1), ///< Bindless sampled images are created with ::zeImageCreate by combining
///< BINDLESS and SAMPLED_IMAGE.
///< Create sampled image view from bindless unsampled image using SAMPLED_IMAGE.
ZE_IMAGE_BINDLESS_EXP_FLAG_FORCE_UINT32 = 0x7fffffff

} ze_image_bindless_exp_flag_t;
Expand All @@ -10564,6 +10570,8 @@ typedef struct _ze_image_bindless_exp_desc_t
///< When the flag is passed to ::zeImageCreate, then only the memory for
///< the image is allocated.
///< Additional image handles can be created with ::zeImageViewCreateExt.
///< When ::ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE flag is passed,
///< ::ze_sampler_desc_t must be attached via pNext member of ::ze_image_bindless_exp_desc_t.

} ze_image_bindless_exp_desc_t;

Expand Down
2 changes: 1 addition & 1 deletion ze/include/ze_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file ze_ddi.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZE_DDI_H
Expand Down
3 changes: 2 additions & 1 deletion ze/include/zes_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file zes_api.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZES_API_H
Expand Down Expand Up @@ -150,6 +150,7 @@ typedef enum _zes_structure_type_t
ZES_STRUCTURE_TYPE_ENGINE_EXT_PROPERTIES = 0x2b, ///< ::zes_engine_ext_properties_t
ZES_STRUCTURE_TYPE_RESET_PROPERTIES = 0x2c, ///< ::zes_reset_properties_t
ZES_STRUCTURE_TYPE_DEVICE_EXT_PROPERTIES = 0x2d, ///< ::zes_device_ext_properties_t
ZES_STRUCTURE_TYPE_DEVICE_UUID = 0x2e, ///< ::zes_uuid_t
ZES_STRUCTURE_TYPE_POWER_DOMAIN_EXP_PROPERTIES = 0x00020001, ///< ::zes_power_domain_exp_properties_t
ZES_STRUCTURE_TYPE_MEM_BANDWIDTH_COUNTER_BITS_EXP_PROPERTIES = 0x00020002, ///< ::zes_mem_bandwidth_counter_bits_exp_properties_t
ZES_STRUCTURE_TYPE_MEMORY_PAGE_OFFLINE_STATE_EXP = 0x00020003, ///< ::zes_mem_page_offline_state_exp_t
Expand Down
2 changes: 1 addition & 1 deletion ze/include/zes_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file zes_ddi.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZES_DDI_H
Expand Down
2 changes: 1 addition & 1 deletion ze/include/zet_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file zet_api.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZET_API_H
Expand Down
2 changes: 1 addition & 1 deletion ze/include/zet_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*
* @file zet_ddi.h
* @version v1.9-r1.9.1
* @version v1.9-r1.9.3
*
*/
#ifndef _ZET_DDI_H
Expand Down
36 changes: 30 additions & 6 deletions ze/tracer_ze_helpers.include.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static int _do_cleanup = 0;
static int _do_chained_structs = 0;
static int _do_paranoid_drift = 0;
static int _do_paranoid_memory_location = 0;
static int _do_ddi_table_forward = 0;

pthread_mutex_t ze_closures_mutex = PTHREAD_MUTEX_INITIALIZER;

Expand Down Expand Up @@ -627,6 +628,10 @@ static pthread_once_t _init = PTHREAD_ONCE_INIT;
static __thread volatile int in_init = 0;
static volatile unsigned int _initialized = 0;

static pthread_once_t _init_dump = PTHREAD_ONCE_INIT;
static __thread volatile int in_init_dump = 0;
static volatile unsigned int _initialized_dump = 0;

static inline int _do_state() {
return _do_profile ||
tracepoint_enabled(lttng_ust_ze_properties, memory_info_properties) ||
Expand Down Expand Up @@ -814,13 +819,11 @@ static void _load_tracer(void) {
if (s)
_do_chained_structs = 1;

find_ze_symbols(handle, verbose);

//FIX for intel tracing layer that needs to register its callbacks first...
ZE_INIT_PTR(0);
s = getenv("LTTNG_UST_ZE_DDI_TABLE_FORWARD");
if (s)
_do_ddi_table_forward = 1;

if (tracepoint_enabled(lttng_ust_ze_properties, driver) || tracepoint_enabled(lttng_ust_ze_properties, device) || tracepoint_enabled(lttng_ust_ze_properties, subdevice))
_dump_properties();
find_ze_symbols(handle, verbose);

s = getenv("LTTNG_UST_ZE_PROFILE");
if (s)
Expand All @@ -845,6 +848,13 @@ static void _load_tracer(void) {
#endif
}

static void _load_tracer_dump(void) {
//FIX for intel tracing layer that needs to register its callbacks first...
ZE_INIT_PTR(0);
if (tracepoint_enabled(lttng_ust_ze_properties, driver) || tracepoint_enabled(lttng_ust_ze_properties, device) || tracepoint_enabled(lttng_ust_ze_properties, subdevice))
_dump_properties();
}

static inline void _init_tracer(void) {
if( __builtin_expect (_initialized, 1) )
return;
Expand All @@ -858,3 +868,17 @@ static inline void _init_tracer(void) {
}
_initialized = 1;
}

static inline void _init_tracer_dump(void) {
if( __builtin_expect (_initialized_dump, 1) )
return;
/* Avoid reentrancy */
if (!in_init_dump) {
in_init_dump=1;
__sync_synchronize();
pthread_once(&_init_dump, _load_tracer_dump);
__sync_synchronize();
in_init_dump=0;
}
_initialized_dump = 1;
}
2 changes: 1 addition & 1 deletion ze/ze_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def upper_snake_case(str)
child_types = STRUCT_MAP.select { |k, _| k.match(parent_type) }
str = <<EOF
#{c.type} _retval;
if (pDdiTable && version <= ZE_API_VERSION_CURRENT) {
if (!_do_ddi_table_forward && pDdiTable && version <= ZE_API_VERSION_CURRENT) {
EOF
str << " "
str << child_types.reverse_each.collect { |k, v|
Expand Down

0 comments on commit 89f8a19

Please sign in to comment.