Skip to content
Snippets Groups Projects
Commit aa731a58 authored by Łukasz Plewa's avatar Łukasz Plewa
Browse files

Merge commit '77326fbc'

parents bc405583 77326fbc
No related branches found
No related tags found
No related merge requests found
Showing
with 151 additions and 15 deletions
......@@ -68,8 +68,11 @@ if(PANDOC)
runtime_wait_multiple)
# install manpages
install(FILES ${MAN_DIR}/miniasync.7
DESTINATION ${CMAKE_INSTALL_MANDIR}/man7)
install(DIRECTORY ${MAN_DIR}/
DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
FILES_MATCHING
PATTERN "*.7"
PATTERN "tmp" EXCLUDE)
install(DIRECTORY ${MAN_DIR}/
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3
FILES_MATCHING
......
---
layout: manual
Content-Style: 'text/css'
title: _MP(VDM_IS_SUPPORTED, 3)
collection: miniasync
header: VDM_IS_SUPPORTED
secondary_title: miniasync
...
[comment]: <> (SPDX-License-Identifier: BSD-3-Clause)
[comment]: <> (Copyright 2022, Intel Corporation)
[comment]: <> (vdm_is_supported.3 -- man page for miniasync vdm_is_supported operation)
[NAME](#name)<br />
[SYNOPSIS](#synopsis)<br />
[DESCRIPTION](#description)<br />
[RETURN VALUE](#return-value)<br />
[SEE ALSO](#see-also)<br />
# NAME #
**vdm_is_supported**() - returns information if a given capability is supported
# SYNOPSIS #
```c
#include <libminiasync.h>
static inline int vdm_is_supported(struct vdm *vdm, unsigned capability);
```
# DESCRIPTION #
**vdm_is_supported**() verifies if the given *vdm* supports a given flag, or other capability.
Currently vdm defines the following capabilities:
- **VDM_F_NO_CACHE_HINT** - If supported, user can pass this flag to the **vdm_memcpy**(), **vdm_memset**(), **vdm_memmove**()
functions, to hint vdm to bypass CPU cache, and write the data directly to the memory. If not supported vdm will ignore this flag.
- **VDM_F_MEM_DURABLE** -- If supported, user can pass this flag **vdm_memcpy**(), **vdm_memset**(), **vdm_memmove**() functions
to ensure that the data written has become persistent, when a future completes.
## RETURN VALUE ##
The **vdm_is_supported**() function returns nonzero if the given capability is supported, or zero otherwise.
# SEE ALSO #
**vdm_memmove**(3), **vdm_memset**(3), **miniasync**(7), **miniasync_vdm**(7),
**miniasync_vdm_dml**(7) and **<https://pmem.io>**
......@@ -11,6 +11,8 @@
#include "core/util.h"
#include "libminiasync-vdm-dml.h"
#define SUPPORTED_FLAGS VDM_F_MEM_DURABLE | VDM_F_NO_CACHE_HINT
struct data_mover_dml {
struct vdm base; /* must be first */
dml_path_t path;
......@@ -23,9 +25,9 @@ struct data_mover_dml {
static void
data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags)
{
ASSERTeq((flags & ~MINIASYNC_DML_F_VALID_FLAGS), 0);
ASSERTeq((flags & ~VDM_F_VALID_FLAGS), 0);
*dml_flags = 0;
*dml_flags = DML_FLAG_PREFETCH_CACHE;
for (uint64_t iflag = 1; flags > 0; iflag = iflag << 1) {
if ((flags & iflag) == 0)
continue;
......@@ -35,9 +37,11 @@ data_mover_dml_translate_flags(uint64_t flags, uint64_t *dml_flags)
* write to destination is identified as write to
* durable memory
*/
case MINIASYNC_DML_F_MEM_DURABLE:
case VDM_F_MEM_DURABLE:
*dml_flags |= DML_FLAG_DST1_DURABLE;
break;
case VDM_F_NO_CACHE_HINT:
*dml_flags &= ~DML_FLAG_PREFETCH_CACHE;
default: /* shouldn't be possible */
ASSERT(0);
}
......@@ -217,6 +221,7 @@ static struct vdm data_mover_dml_vdm = {
.op_delete = data_mover_dml_operation_delete,
.op_check = data_mover_dml_operation_check,
.op_start = data_mover_dml_operation_start,
.capabilities = SUPPORTED_FLAGS,
};
/*
......
......@@ -18,12 +18,6 @@
extern "C" {
#endif
/* MINIASYNC_DML flags */
/* XXX: these flags need to be unified across all vdms */
#define MINIASYNC_DML_F_MEM_DURABLE (1U << 0)
#define MINIASYNC_DML_F_VALID_FLAGS (MINIASYNC_DML_F_MEM_DURABLE)
#ifdef __cplusplus
}
#endif
......
......@@ -11,6 +11,8 @@
#include "core/membuf.h"
#include "core/out.h"
#define SUPPORTED_FLAGS 0
struct data_mover_sync {
struct vdm base; /* must be first */
......@@ -134,6 +136,7 @@ static struct vdm data_mover_sync_vdm = {
.op_delete = sync_operation_delete,
.op_check = sync_operation_check,
.op_start = sync_operation_start,
.capabilities = SUPPORTED_FLAGS,
};
/*
......
......@@ -18,6 +18,8 @@
#define DATA_MOVER_THREADS_DEFAULT_NTHREADS 12
#define DATA_MOVER_THREADS_DEFAULT_RINGBUF_SIZE 128
#define SUPPORTED_FLAGS 0
struct data_mover_threads_op_fns {
memcpy_fn op_memcpy;
memmove_fn op_memmove;
......@@ -271,6 +273,7 @@ static struct vdm data_mover_threads_vdm = {
.op_delete = data_mover_threads_operation_delete,
.op_check = data_mover_threads_operation_check,
.op_start = data_mover_threads_operation_start,
.capabilities = SUPPORTED_FLAGS,
};
/*
......
......@@ -124,6 +124,7 @@ struct vdm {
vdm_operation_delete op_delete;
vdm_operation_start op_start;
vdm_operation_check op_check;
unsigned capabilities;
};
struct vdm *vdm_synchronous_new(void);
......@@ -162,6 +163,19 @@ vdm_operation_impl(struct future_context *context, struct future_notifier *n)
return state;
}
#define VDM_F_MEM_DURABLE (1U << 0)
#define VDM_F_NO_CACHE_HINT (1U << 1)
#define VDM_F_VALID_FLAGS (VDM_F_MEM_DURABLE | VDM_F_NO_CACHE_HINT)
/*
* vdm_is_supported -- returns if the given flag or feature is supported
*/
static inline int
vdm_is_supported(struct vdm *vdm, unsigned capability)
{
return (vdm->capabilities && capability) == capability;
}
/*
* vdm_generic_operation -- creates a new vdm future for a given generic
* operation
......@@ -193,6 +207,7 @@ vdm_memcpy(struct vdm *vdm, void *dest, void *src, size_t n, uint64_t flags)
future.data.operation.data.memcpy.flags = flags;
future.data.operation.data.memcpy.n = n;
future.data.operation.data.memcpy.src = src;
future.data.operation.padding = 0;
future.output.type = VDM_OPERATION_MEMCPY;
future.output.result = VDM_SUCCESS;
future.output.output.memcpy.dest = NULL;
......@@ -214,6 +229,7 @@ vdm_memmove(struct vdm *vdm, void *dest, void *src, size_t n, uint64_t flags)
future.data.operation.data.memmove.flags = flags;
future.data.operation.data.memmove.n = n;
future.data.operation.data.memmove.src = src;
future.data.operation.padding = 0;
future.output.type = VDM_OPERATION_MEMMOVE;
future.output.result = VDM_SUCCESS;
future.output.output.memmove.dest = NULL;
......@@ -235,6 +251,7 @@ vdm_memset(struct vdm *vdm, void *str, int c, size_t n, uint64_t flags)
future.data.operation.data.memset.flags = flags;
future.data.operation.data.memset.n = n;
future.data.operation.data.memset.c = c;
future.data.operation.padding = 0;
future.output.type = VDM_OPERATION_MEMSET;
future.output.result = VDM_SUCCESS;
future.output.output.memset.str = NULL;
......
......@@ -59,9 +59,11 @@ add_custom_target(tests)
add_flag(-Wall)
add_cstyle(tests-all
${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch])
${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/*.[ch])
add_check_whitespace(tests-all
${CMAKE_CURRENT_SOURCE_DIR}/*/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
"${CMAKE_CURRENT_SOURCE_DIR}/*/*[.cmake]"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/*[.cmake]")
......
......@@ -7,6 +7,7 @@
#include <libminiasync.h>
#include <libminiasync-vdm-dml.h>
#include "test_helpers.h"
#include "util_dml.h"
static int
......@@ -46,7 +47,7 @@ test_dml_basic_memcpy()
static int
test_dml_durable_flag_memcpy()
{
return dml_memcpy(DATA_MOVER_DML_SOFTWARE, MINIASYNC_DML_F_MEM_DURABLE);
return dml_memcpy(DATA_MOVER_DML_SOFTWARE, VDM_F_MEM_DURABLE);
}
static int
......@@ -55,6 +56,20 @@ test_dml_hw_path_flag_memcpy()
return dml_memcpy(DATA_MOVER_DML_HARDWARE, 0);
}
/*
* test_supported_flags -- test if data_mover_threads support correct flags
*/
int test_supported_flags() {
struct data_mover_dml *dmd =
data_mover_dml_new(DATA_MOVER_DML_SOFTWARE);
struct vdm *dml_mover = data_mover_dml_get_vdm(dmd);
int ret = test_flag(dml_mover, VDM_F_MEM_DURABLE, 1);
ret += test_flag(dml_mover, VDM_F_NO_CACHE_HINT, 1);
data_mover_dml_delete(dmd);
return ret;
}
int
main(void)
{
......@@ -72,5 +87,9 @@ main(void)
return ret;
}
ret = test_supported_flags();
if (ret)
return ret;
return 0;
}
......@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include "libminiasync.h"
#include "test_helpers.h"
/*
* test_basic_memmove -- tests memmove vdm operation
......@@ -159,6 +160,18 @@ test_memmove_overlapping(size_t size)
return ret;
}
/*
* test_supported_flags -- test if data_mover_sync support correct flags
*/
int test_supported_flags() {
struct data_mover_sync *dms = data_mover_sync_new();
struct vdm *sync_mover = data_mover_sync_get_vdm(dms);
int ret = test_flag(sync_mover, VDM_F_MEM_DURABLE, 0);
ret += test_flag(sync_mover, VDM_F_NO_CACHE_HINT, 0);
data_mover_sync_delete(dms);
return ret;
}
int
main(void)
{
......@@ -166,5 +179,6 @@ main(void)
test_basic_memmove() ||
test_memmove_overlapping(4) ||
test_memmove_overlapping(12) ||
test_memmove_overlapping(1024);
test_memmove_overlapping(1024) ||
test_supported_flags();
}
......@@ -141,6 +141,18 @@ test_thread_memmove_multiple(size_t str_len)
return ret;
}
/*
* test_supported_flags -- test if data_mover_threads support correct flags
*/
int test_supported_flags() {
struct data_mover_threads *dmt = data_mover_threads_default();
struct vdm *thread_mover = data_mover_threads_get_vdm(dmt);
int ret = test_flag(thread_mover, VDM_F_MEM_DURABLE, 0);
data_mover_threads_delete(dmt);
return ret;
}
int
main(void)
{
......@@ -150,5 +162,6 @@ main(void)
test_thread_memmove_single(50000000) ||
test_thread_memmove_multiple(10000000) ||
test_thread_memmove_multiple(30000000) ||
test_thread_memmove_multiple(50000000);
test_thread_memmove_multiple(50000000) ||
test_supported_flags();
}
......@@ -15,6 +15,7 @@
#include <limits.h>
#include <assert.h>
#include <errno.h>
#include "libminiasync/vdm.h"
#define UT_ERR(...) do {\
fprintf(stderr, "ERROR: " __VA_ARGS__);\
......@@ -45,4 +46,16 @@
(unsigned long long)(min), (unsigned long long)(max));\
} while (/*CONSTCOND*/0)
static inline int
test_flag(struct vdm *vdm, unsigned flag, int expected_value)
{
int ret = vdm_is_supported(vdm, flag) != expected_value;
if (ret) {
fprintf(stderr,
"vdm_is_flag_supported(%u) returned: %u, when expected: %u\n",
flag, ret, expected_value);
}
return ret;
}
#endif /* TEST_HELPERS_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment