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

Fix CtsGpuProfilingDataTest fail #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions android/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ ifneq ($(strip $(BOARD_MESA3D_GALLIUM_DRIVERS)),)
$(eval $(call mesa3d-lib,libgallium_dri,.so.0,dri,MESA3D_GALLIUM_DRI_BIN))
# Module 'libglapi', produces '/vendor/lib{64}/libglapi.so'
$(eval $(call mesa3d-lib,libglapi,.so.0,,MESA3D_LIBGLAPI_BIN))
# Module 'libpps-producer', produces '/vendor/lib{64}/libpps-producer.so'
$(eval $(call mesa3d-lib,libpps-producer,.so.0,,MESA3D_LIBPPS_PRODUCER))
# Module 'libgpudataproducer', produces '/vendor/lib{64}/libgpudataproducer.so'
$(eval $(call mesa3d-lib,libgpudataproducer,.so.0,,MESA3D_LIBPPS_PRODUCER))

# Module 'libEGL_mesa', produces '/vendor/lib{64}/egl/libEGL_mesa.so'
$(eval $(call mesa3d-lib,libEGL_mesa,.so.1,egl,MESA3D_LIBEGL_BIN))
Expand All @@ -220,10 +220,9 @@ endif
#-------------------------------------------------------------------------------

include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES := libpps-producer
LOCAL_SRC_FILES := perfetto/pps-producer.cc
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE := pps-producer
LOCAL_MODULE := gpudataproducer
LOCAL_CPP_EXTENSION := .cc
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
Expand Down
1 change: 1 addition & 0 deletions android/mesa3d_cross.mk
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ MESON_GEN_NINJA := \
-Dlmsensors=disabled \
-Dandroid-libbacktrace=disabled \
-Dperfetto=true \
-Ddatasources=auto \
$(BOARD_MESA3D_MESON_ARGS) \

MESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build
Expand Down
29 changes: 27 additions & 2 deletions android/perfetto/pps-producer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
extern int pps_main(int argc, const char **argv);
#include <cstdio>
#include <dlfcn.h>

typedef void (*pps_main_fn_t)(int, const char **);

#define PPS_LIB "/vendor/lib64/libgpudataproducer.so"

int main(int argc, const char **argv) {
return pps_main(argc, argv);
char *error;

void *handle = dlopen(PPS_LIB, RTLD_GLOBAL);
if ((error = dlerror()) != nullptr || handle == nullptr) {
fprintf(stdout, "Error loading lib: %s\n", error);
return -1;
}

pps_main_fn_t ppsFn = (pps_main_fn_t)dlsym(handle, "pps_main");
if (((error = dlerror()) != nullptr) || (ppsFn == nullptr)) {
fprintf(stdout, "Error looking for pps_main symbol: %s\n", error);
dlclose(handle);
return -1;
}

fprintf(stdout, "start call pps_main\n");
(*ppsFn)(argc, argv);
fprintf(stdout, "end call pps_main\n");

dlclose(handle);
return 0;
}
5 changes: 5 additions & 0 deletions src/intel/ds/intel_driver_ds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,12 @@ intel_driver_ds_init_once(void)
#ifdef HAVE_PERFETTO
util_perfetto_init();
perfetto::DataSourceDescriptor dsd;
#ifdef ANDROID
/* AGI requires this name */
dsd.set_name("gpu.renderstages");
#else
dsd.set_name("gpu.renderstages.intel");
#endif
IntelRenderpassDataSource::Register(dsd);
#endif
}
Expand Down
10 changes: 9 additions & 1 deletion src/intel/ds/intel_pps_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "drm-uapi/i915_drm.h"

#include "common/intel_gem.h"
#include <cutils/properties.h>
#include "dev/intel_device_info.h"
#include "perf/intel_perf.h"
#include "perf/intel_perf_query.h"
Expand Down Expand Up @@ -85,7 +86,14 @@ bool IntelDriver::init_perfcnt()

perf = std::make_unique<IntelPerf>(drm_device.fd);

const char *metric_set_name = getenv("INTEL_PERFETTO_METRIC_SET");
const char *metric_set_name = NULL;
#ifdef ANDROID
char metric_set_buf[PROPERTY_VALUE_MAX] = "";
if (property_get("persist.vendor.intel.perfetto.metric_set", metric_set_buf, NULL) > 0)
metric_set_name = metric_set_buf;
#else
metric_set_name = getenv("INTEL_PERFETTO_METRIC_SET");
#endif

struct intel_perf_query_info *default_query = nullptr;
selected_query = nullptr;
Expand Down
9 changes: 9 additions & 0 deletions src/tool/pps/cfg/gpu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ data_sources {
}
}

data_sources {
config {
name: "gpu.counters"
gpu_counter_config {
counter_period_ns: 1000000000
}
}
}

duration_ms: 16000
15 changes: 15 additions & 0 deletions src/tool/pps/cfg/intel.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ data_sources {
}
}

data_sources {
config {
name: "gpu.counters"
gpu_counter_config {
counter_period_ns: 100000
}
}
}

data_sources {
config {
name: "gpu.renderstages"
}
}

data_sources {
config {
name: "track_event"
Expand Down
15 changes: 15 additions & 0 deletions src/tool/pps/cfg/system.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ data_sources {
}
}

data_sources {
config {
name: "gpu.counters"
gpu_counter_config {
counter_period_ns: 100000
}
}
}

data_sources {
config {
name: "gpu.renderstages"
}
}

data_sources {
config {
name: "track_event"
Expand Down
9 changes: 9 additions & 0 deletions src/tool/pps/pps_datasource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void GpuDataSource::OnSetup(const SetupArgs &args)
}

this->driver = driver;
// use first available driver, to avoid be covered by following failed driver.
break;
}
}
if (driver == nullptr) {
Expand Down Expand Up @@ -324,7 +326,12 @@ void GpuDataSource::register_data_source(const std::string &_driver_name)
{
driver_name = _driver_name;
static perfetto::DataSourceDescriptor dsd;
#ifdef ANDROID
/* AGI requires this name */
dsd.set_name("gpu.counters");
#else
dsd.set_name("gpu.counters." + driver_name);
#endif

Driver * driver = nullptr;
auto drm_devices = DrmDevice::create_all();
Expand All @@ -336,6 +343,8 @@ void GpuDataSource::register_data_source(const std::string &_driver_name)
if ((driver != nullptr) && !driver->init_perfcnt()) {
driver = nullptr;
}
// use first available driver, to avoid be covered by following failed driver.
break;
}

if (driver != nullptr) {
Expand Down
21 changes: 20 additions & 1 deletion src/tool/pps/pps_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "pps_datasource.h"

int pps_main(int argc, const char **argv)
extern "C" int pps_main(int argc, const char **argv)
{
using namespace pps;

Expand All @@ -35,3 +35,22 @@ int pps_main(int argc, const char **argv)

return EXIT_SUCCESS;
}

extern "C" void start()
{
using namespace pps;

// Connects to the system tracing service
perfetto::TracingInitArgs args;
args.backends = perfetto::kSystemBackend;
perfetto::Tracing::Initialize(args);

GpuDataSource::register_data_source(Driver::default_driver_name());

while (true) {
GpuDataSource::wait_started();
GpuDataSource::Trace(GpuDataSource::trace_callback);
}

return;
}
Loading