Skip to content

Commit

Permalink
Sync with the upstream
Browse files Browse the repository at this point in the history
1. Sync with the upstream
2. Update CMakePresets.json to avoid hardcoding LLVM's installation path.
3. Enable CodeQL
  • Loading branch information
snnn committed Oct 18, 2024
1 parent 1912e05 commit 2c8dfa8
Show file tree
Hide file tree
Showing 18 changed files with 1,122 additions and 341 deletions.
8 changes: 8 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "CodeQL config"
queries:
- uses: security-extended
- uses: security-and-quality
paths-ignore:
- tests
- lib
- build
38 changes: 37 additions & 1 deletion .github/workflows/linux_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,57 @@ on:
branches:
- main
- rel-*
- snnn/*
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Linux_arm64_gcc_release:
runs-on: ["self-hosted", "1ES.Pool=mlas-linux-ARM64-CPU"]
steps:
- uses: actions/checkout@v4
- run: |
set -e -x
rm -rf build
cmake --workflow --preset linux_gcc_release_workflow
Linux_x64_gcc_ubuntu24_release:
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
config-file: ./.github/codeql/codeql-config.yml
languages: 'cpp'
- run: |
set -e -x
rm -rf build
cmake --workflow --preset linux_gcc_release_workflow
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"
output: sarif-results

- name: filter-sarif
uses: advanced-security/filter-sarif@v1
with:
patterns: |
+**/*.cc
+**/*.h
-tests/**/*.*
-build/**/*.*
input: sarif-results/cpp.sarif
output: sarif-results/cpp.sarif

Linux_x64_gcc_ubuntu22_release:
runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -86,4 +122,4 @@ jobs:
cd ..
CFLAGS="-O2 -DNDEBUG -g" CXXFLAGS="-O2 -DNDEBUG -g" emcmake cmake .. -DCMAKE_BUILD_TYPE=Release -DMLAS_ENABLE_WEBASSEMBLY_THREADS=ON
make -j $(nproc) all
ctest --output-on-failure
ctest --output-on-failure
2 changes: 1 addition & 1 deletion cmake/deps.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
eigen;https://gitlab.com/libeigen/eigen/-/archive/e7248b26a1ed53fa030c5c459f7ea095dfd276ac/eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.zip;be8be39fdbc6e60e94fa7870b280707069b5b81a
eigen;https://gitlab.com/libeigen/eigen/-/archive/ff174f79264d3f8dc0115dea7a288f98208b694f/eigen-ff174f79264d3f8dc0115dea7a288f98208b694f.zip;e06074b74725f2677369be2eb2e97e57e2dc4353
microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.zip;cf368104cd22a87b4dd0c80228919bb2df3e2a14
googletest;https://github.com/google/googletest/archive/refs/tags/v1.15.0.zip;9d2d0af8d77ac726ea55d44a8fa727ec98311349
google_benchmark;https://github.com/google/benchmark/archive/refs/tags/v1.8.5.zip;cd47d3d272faf353600c8cc2fdec2b52d6f69177
8 changes: 1 addition & 7 deletions include/core/common/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ namespace logging {

using Timestamp = std::chrono::time_point<std::chrono::system_clock>;

// TODO: When other compilers support std::chrono::operator<<, update this.
// TODO: Check support for other compilers' version before enable C++20 for other compilers.
// Xcode added support for C++20's std::chrono::operator<< in SDK version 14.4.
#if __cplusplus >= 202002L && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140400L

namespace timestamp_ns = std::chrono;
#else
namespace timestamp_ns = ::date;
#endif

#ifndef NDEBUG
ORT_ATTRIBUTE_UNUSED static bool vlog_enabled = true; // Set directly based on your needs.
Expand Down
Empty file.
39 changes: 0 additions & 39 deletions include/core/platform/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ limitations under the License.
#include "core/common/common.h"
#include "core/common/path_string.h"
#include "core/framework/callback.h"
#include "core/platform/env_time.h"
#include "core/platform/telemetry.h"
#include "core/session/onnxruntime_c_api.h"

#ifndef _WIN32
Expand All @@ -51,12 +49,6 @@ using FileOffsetType = off_t;
class EnvThread {
public:
virtual ~EnvThread() = default;

protected:
OrtCustomCreateThreadFn custom_create_thread_fn = nullptr;
void* custom_thread_creation_options = nullptr;
OrtCustomJoinThreadFn custom_join_thread_fn = nullptr;
OrtCustomThreadHandle custom_thread_handle = nullptr;
};

/// Type that holds a collection of logical processors IDs used for setting affinities.
Expand Down Expand Up @@ -87,10 +79,6 @@ struct ThreadOptions {
// Set or unset denormal as zero.
bool set_denormal_as_zero = false;

OrtCustomCreateThreadFn custom_create_thread_fn = nullptr;
void* custom_thread_creation_options = nullptr;
OrtCustomJoinThreadFn custom_join_thread_fn = nullptr;
int dynamic_block_base_ = 0;
};

std::ostream& operator<<(std::ostream& os, const LogicalProcessors&);
Expand Down Expand Up @@ -149,16 +137,6 @@ class Env {

virtual int GetL2CacheSize() const = 0;

/// \brief Returns the number of micro-seconds since the Unix epoch.
virtual uint64_t NowMicros() const {
return env_time_->NowMicros();
}

/// \brief Returns the number of seconds since the Unix epoch.
virtual uint64_t NowSeconds() const {
return env_time_->NowSeconds();
}

/// Sleeps/delays the thread for the prescribed number of micro-seconds.
/// On Windows, it's the min time to sleep, not the actual one.
virtual void SleepForMicroseconds(int64_t micros) const = 0;
Expand All @@ -179,20 +157,7 @@ class Env {
virtual common::Status ReadFileIntoBuffer(_In_z_ const ORTCHAR_T* file_path, FileOffsetType offset, size_t length,
gsl::span<char> buffer) const = 0;

using MappedMemoryPtr = std::unique_ptr<char[], OrtCallbackInvoker>;

/**
* Maps the content of the file into memory.
* This is a copy-on-write mapping, so any changes are not written to the
* actual file.
* @param file_path The path to the file.
* @param offset The file offset from which to start the mapping.
* @param length The length in bytes of the mapping.
* @param[out] mapped_memory A smart pointer to the mapped memory which
* unmaps the memory (unless release()'d) when destroyed.
*/
virtual common::Status MapFileIntoMemory(_In_z_ const ORTCHAR_T* file_path, FileOffsetType offset, size_t length,
MappedMemoryPtr& mapped_memory) const = 0;

#ifdef _WIN32
/// \brief Returns true if the directory exists.
Expand Down Expand Up @@ -263,9 +228,6 @@ class Env {
// returns the name that LoadDynamicLibrary() can use
virtual std::string FormatLibraryFileName(const std::string& name, const std::string& version) const = 0;

// \brief returns a provider that will handle telemetry on the current platform
virtual const Telemetry& GetTelemetryProvider() const = 0;

// \brief returns a value for the queried variable name (var_name)
//
// Returns the corresponding value stored in the environment variable if available
Expand All @@ -277,7 +239,6 @@ class Env {

private:
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Env);
EnvTime* env_time_ = EnvTime::Default();
};

} // namespace onnxruntime
5 changes: 0 additions & 5 deletions include/core/util/thread_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ struct OrtThreadPoolParams {

// Set or unset denormal as zero
bool set_denormal_as_zero = false;

// members to manage custom threads
OrtCustomCreateThreadFn custom_create_thread_fn = nullptr;
void* custom_thread_creation_options = nullptr;
OrtCustomJoinThreadFn custom_join_thread_fn = nullptr;
};

std::ostream& operator<<(std::ostream& os, const OrtThreadPoolParams& params);
Expand Down
3 changes: 2 additions & 1 deletion src/common/logging/sinks/ostream_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void OStreamSink::SendImpl(const Timestamp& timestamp, const std::string& logger
}
#endif

msg << timestamp << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
timestamp_ns::operator<<(msg, timestamp); // handle ambiguity with C++20 where date and std::chrono have operator<<
msg << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
<< message.Location().ToString() << "] " << message.Message();

#ifndef ORT_MINIMAL_BUILD
Expand Down
Loading

0 comments on commit 2c8dfa8

Please sign in to comment.