[CCF Archive] Store object type eviction policy submission #3

Closed
kancel wants to merge 382 commits from kancel:ccf-archive-pr2746 into main
7 changed files with 44 additions and 10 deletions
Showing only changes of commit b92cf05ff7 - Show all commits

View File

@ -17,6 +17,7 @@
#include "te_backend.h"
#include "utils.h"
#include "common.h"
#include "char_util.h"
#if defined(USE_CUDA)
#include <bits/stdint-uintn.h>
@ -50,7 +51,7 @@ static inline int getCudaDeviceNumaID(int cuda_id) {
LOG(WARNING) << "cudaDeviceGetPCIBusId: " << cudaGetErrorString(err);
return 0;
}
for (char* ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char* ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
return getNumaNodeFromPciDevice(pci_bus_id);
}
#elif defined(USE_SUNRISE)
@ -63,7 +64,7 @@ static inline int getSunriseDeviceNumaID(int dev_id) {
<< tangGetErrorString(err);
return 0;
}
for (char* ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char* ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
std::string sysfs_path =
"/sys/bus/pci/devices/" + std::string(pci_bus_id) + "/numa_node";
std::ifstream numa_file(sysfs_path);

View File

@ -14,6 +14,7 @@
#include "tent_backend.h"
#include "utils.h"
#include "char_util.h"
#include "tent/common/types.h"
#include "tent/runtime/platform.h"
#include "tent/runtime/topology.h"
@ -257,7 +258,7 @@ static inline int getGpuDeviceNumaID(int gpu_id) {
LOG(WARNING) << "cudaDeviceGetPCIBusId: " << cudaGetErrorString(err);
return 0;
}
for (char* ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char* ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
return getNumaNodeFromPciDevice(pci_bus_id);
}
#elif defined(USE_HIP)

View File

@ -0,0 +1,31 @@
// Copyright 2024 KVCache.AI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CHAR_UTIL_H
#define CHAR_UTIL_H
#include <cctype>
namespace mooncake {
// Lowercase a single byte safely. Passing a (possibly signed) char straight
// to std::tolower is UB when the byte is > 0x7F; the argument must be
// representable as unsigned char or equal EOF.
static inline char to_lower(char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
}
} // namespace mooncake
#endif // CHAR_UTIL_H

View File

@ -22,7 +22,6 @@
#include <string>
#include <utility>
#include <vector>
#include <ctype.h>
#include <dirent.h>
#include <infiniband/verbs.h>
#include <limits.h>
@ -34,6 +33,7 @@
#include "cuda_alike.h"
#include "memory_location.h"
#include "topology.h"
#include "char_util.h"
#ifdef USE_UB
#include <libgen.h>
#include <urma_api.h>
@ -447,7 +447,7 @@ static std::vector<TopologyEntry> discoverCudaTopology(
cudaSuccess) {
continue;
}
for (char *ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char *ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
std::vector<std::string> preferred_hca;
std::vector<std::string> avail_hca;

View File

@ -16,6 +16,7 @@
#include "tent/common/status.h"
#include "tent/common/utils/prefault.h"
#include "tent/common/utils/random.h"
#include "char_util.h"
#include <glog/logging.h>
#include <fstream>
@ -26,7 +27,6 @@
#include <utility>
#include <vector>
#include <cuda_runtime.h>
#include <ctype.h>
#include <dirent.h>
#include <infiniband/verbs.h>
#include <limits.h>
@ -191,7 +191,7 @@ static void discoverCudaTopology(std::vector<Topology::NicEntry>& nic_list,
<< cudaGetErrorString(err);
continue;
}
for (char* ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char* ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
int numa_node = getNumaNodeFromPciDevice(pci_bus_id);
int min_distance = INT_MAX;
std::unordered_map<int, std::vector<int>> distance_map;

View File

@ -15,6 +15,7 @@
#include "tent/platform/rocm.h"
#include "tent/common/status.h"
#include "tent/common/utils/prefault.h"
#include "char_util.h"
#include <glog/logging.h>
#include <fstream>
@ -24,7 +25,6 @@
#include <utility>
#include <vector>
#include <hip/hip_runtime.h>
#include <ctype.h>
#include <dirent.h>
#include <infiniband/verbs.h>
#include <limits.h>
@ -182,7 +182,7 @@ static void discoverRocmTopology(std::vector<Topology::NicEntry>& nic_list,
char pci_bus_id[20];
snprintf(pci_bus_id, sizeof(pci_bus_id), "%04x:%02x:%02x.%x",
prop.pciDomainID, prop.pciBusID, prop.pciDeviceID, 0);
for (char* ch = pci_bus_id; *ch; ch++) *ch = tolower(*ch);
for (char* ch = pci_bus_id; *ch; ch++) *ch = to_lower(*ch);
int numa_node = getNumaNodeFromPciDevice(pci_bus_id);
int min_distance = INT_MAX;

View File

@ -15,6 +15,7 @@
#include "tent/runtime/memory_prober.h"
#include "tent/device_plugin.h"
#include "tent/common/utils/prefault.h"
#include "char_util.h"
#include <filesystem>
#include <dlfcn.h>
@ -374,7 +375,7 @@ void MemoryProber::probeDeviceMemory(
sizeof(pci_bus_id));
if (err) continue;
for (char* ch = pci_bus_id; (*ch = tolower(*ch)); ch++);
for (char* ch = pci_bus_id; (*ch = to_lower(*ch)); ch++);
int numa_node = getNumaNodeFromPciDevice(pci_bus_id);
int min_distance = INT_MAX;
std::unordered_map<int, std::vector<int>> distance_map;