Skip to content

Commit

Permalink
Adding support for arm64 arch compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Hayden Laccabue <[email protected]>
  • Loading branch information
hlaccabu committed Jan 29, 2025
1 parent 9b5217e commit f61ca9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
13 changes: 13 additions & 0 deletions src/shim/bo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@
#include "drm_local/amdxdna_accel.h"
#include <string>
#include <atomic>
#if defined(__x86_64__) || defined(_M_X64)
#include <x86intrin.h>
#endif

namespace shim_xdna {

const int LINESIZE = 64;

void flush_cache_line(const char *cur) {
#if defined(__x86_64__) || defined(_M_X64)
_mm_clflush(cur);
#else
__builtin___clear_cache((char *)cur, (char *)(cur + LINESIZE));
#endif
}

class bo : public xrt_core::buffer_handle
{
public:
Expand Down
6 changes: 2 additions & 4 deletions src/shim/kmq/bo.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. All rights reserved.
// Copyright (C) 2023-2025, Advanced Micro Devices, Inc. All rights reserved.

#include "bo.h"
#include "core/common/config_reader.h"
#include <x86intrin.h>

namespace {

Expand All @@ -25,7 +24,6 @@ flag_to_type(uint64_t bo_flags)
return AMDXDNA_BO_INVALID;
}


// flash cache line for non coherence memory
inline void
clflush_data(const void *base, size_t offset, size_t len)
Expand All @@ -43,7 +41,7 @@ clflush_data(const void *base, size_t offset, size_t len)
cur += offset;
uintptr_t lastline = (uintptr_t)(cur + len - 1) | (cacheline_size - 1);
do {
_mm_clflush(cur);
shim_xdna::flush_cache_line(cur);
cur += cacheline_size;
} while (cur <= (const char *)lastline);
}
Expand Down
20 changes: 7 additions & 13 deletions src/shim/umq/hwq.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2023-2025, Advanced Micro Devices, Inc. All rights reserved.

#include <x86intrin.h>
#include "bo.h"
#include "hwq.h"

namespace {

// flash cache line for non coherence memory
inline void
clflush_data(void *data, int len)
{
const int LINESIZE = 64;
const char *cur = (const char *)data;
// must be at least one cache line
uintptr_t lastline = (uintptr_t)(cur + len - 1) | (LINESIZE - 1);
do {
_mm_clflush(cur);
cur += LINESIZE;
} while (cur <= (const char *)lastline);
void clflush_data(const void *data, size_t len) {
const char *cur = (const char *)data;
uintptr_t lastline = (uintptr_t)(cur + len - 1) | (shim_xdna::LINESIZE - 1);
do {
shim_xdna::flush_cache_line(cur);
cur += shim_xdna::LINESIZE;
} while (cur <= (const char *)lastline);
}

inline void
Expand Down

0 comments on commit f61ca9e

Please sign in to comment.