Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9eeeddfc authored by Matt Buckley's avatar Matt Buckley Committed by Android (Google) Code Review
Browse files

Merge "Add CPU/GPU_LOAD_SPIKE hints for one-off expensive workloads" into main

parents 65e1a22b 8bd42656
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -393,6 +393,7 @@ LIBANDROID {
    APerformanceHint_createSessionUsingConfig; # introduced=36
    APerformanceHint_notifyWorkloadIncrease; # introduced=36
    APerformanceHint_notifyWorkloadReset; # introduced=36
    APerformanceHint_notifyWorkloadSpike; # introduced=36
    APerformanceHint_borrowSessionFromJava; # introduced=36
    APerformanceHint_setNativeSurfaces; # introduced=36
    AWorkDuration_create; # introduced=VanillaIceCream
+24 −0
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ public:
    int sendHints(std::vector<hal::SessionHint>& hints, int64_t now, const char* debugName);
    int notifyWorkloadIncrease(bool cpu, bool gpu, const char* debugName);
    int notifyWorkloadReset(bool cpu, bool gpu, const char* debugName);
    int notifyWorkloadSpike(bool cpu, bool gpu, const char* debugName);
    int setThreads(const int32_t* threadIds, size_t size);
    int getThreadIds(int32_t* const threadIds, size_t* size);
    int setPreferPowerEfficiency(bool enabled);
@@ -600,6 +601,19 @@ int APerformanceHintSession::notifyWorkloadReset(bool cpu, bool gpu, const char*
    return sendHints(hints, now, debugName);
}

int APerformanceHintSession::notifyWorkloadSpike(bool cpu, bool gpu, const char* debugName) {
    std::vector<hal::SessionHint> hints(2);
    hints.clear();
    if (cpu) {
        hints.push_back(hal::SessionHint::CPU_LOAD_SPIKE);
    }
    if (gpu) {
        hints.push_back(hal::SessionHint::GPU_LOAD_SPIKE);
    }
    int64_t now = ::android::uptimeNanos();
    return sendHints(hints, now, debugName);
}

int APerformanceHintSession::setThreads(const int32_t* threadIds, size_t size) {
    if (size == 0) {
        ALOGE("%s: the list of thread ids must not be empty.", __FUNCTION__);
@@ -1149,6 +1163,16 @@ int APerformanceHint_notifyWorkloadReset(APerformanceHintSession* session, bool
    return session->notifyWorkloadReset(cpu, gpu, debugName);
}

int APerformanceHint_notifyWorkloadSpike(APerformanceHintSession* session, bool cpu, bool gpu,
                                         const char* debugName) {
    VALIDATE_PTR(session)
    VALIDATE_PTR(debugName)
    if (!useNewLoadHintBehavior()) {
        return ENOTSUP;
    }
    return session->notifyWorkloadReset(cpu, gpu, debugName);
}

int APerformanceHint_setNativeSurfaces(APerformanceHintSession* session,
                                       ANativeWindow** nativeWindows, int nativeWindowsSize,
                                       ASurfaceControl** surfaceControls, int surfaceControlsSize) {
+4 −0
Original line number Diff line number Diff line
@@ -299,6 +299,10 @@ TEST_F(PerformanceHintTest, TestSession) {
    EXPECT_CALL(*mMockSession, sendHint(Eq(SessionHint::GPU_LOAD_RESET))).Times(Exactly(1));
    result = APerformanceHint_notifyWorkloadReset(session, true, true, "Test hint");
    EXPECT_EQ(0, result);
    EXPECT_CALL(*mMockSession, sendHint(Eq(SessionHint::CPU_LOAD_SPIKE))).Times(Exactly(1));
    EXPECT_CALL(*mMockSession, sendHint(Eq(SessionHint::GPU_LOAD_SPIKE))).Times(Exactly(1));
    result = APerformanceHint_notifyWorkloadSpike(session, true, true, "Test hint");
    EXPECT_EQ(0, result);

    result = APerformanceHint_sendHint(session, static_cast<SessionHint>(-1));
    EXPECT_EQ(EINVAL, result);