From 233b7e826fcd644fb1bbb9a9949cb2b972437c00 Mon Sep 17 00:00:00 2001
From: Erik von Reis <evonreis@caltech.edu>
Date: Mon, 3 May 2021 18:39:50 -0700
Subject: [PATCH] awgtpman: reversion back to memcpy, since it's much faster
 than a 16 byte copy.

---
 src/gds/awgtpman/awg.c           |  6 ++--
 src/gds/awgtpman/shared_memory.c | 57 --------------------------------
 src/gds/awgtpman/shared_memory.h | 34 -------------------
 3 files changed, 3 insertions(+), 94 deletions(-)

diff --git a/src/gds/awgtpman/awg.c b/src/gds/awgtpman/awg.c
index 8f7b67355..876e0975b 100644
--- a/src/gds/awgtpman/awg.c
+++ b/src/gds/awgtpman/awg.c
@@ -963,12 +963,12 @@ Organization of generating waveforms:
 
          // now start transfer
 
-//         timing test code
+//         // timing test code
 //         clock_t start = clock();
 //         int n = 10;
 //         for(int i=0; i<n; ++i)
-         memcpy_to_vol_aligned(
-             target_page->buf, p->page, p->pagelen * sizeof( float ) );
+         memcpy(
+             (void *)target_page->buf, p->page, p->pagelen * sizeof( float ) );
 
 //         clock_t end = clock();
 //         printf("copy of %d bytes took %e seconds\n",
diff --git a/src/gds/awgtpman/shared_memory.c b/src/gds/awgtpman/shared_memory.c
index b9e5a13bb..b45d3ac97 100644
--- a/src/gds/awgtpman/shared_memory.c
+++ b/src/gds/awgtpman/shared_memory.c
@@ -23,60 +23,3 @@ int OpenAwgDataSharedMemory(const char *model_name)
     AWG_DATA_INIT(shmemAwgData);
     return (shmemAwgData!=NULL) ? -1 : 0;
 }
-
-// large copy alignment. use 16 bytes if we can, otherwise drop back to 8.
-#ifdef __GNUC__
-#define CPY_WORD  __int128_t
-#define CPY_TEST_MASK 0xf
-#else
-#define CPY_WORD  uint64_t
-#define CPY_TEST_MASK 0x7
-#endif
-
-volatile void *
-memcpy_to_vol_aligned(volatile void *dest, const void *src, size_t len)
-{
-    if( ((uint64_t)dest & CPY_TEST_MASK))
-    {
-        fprintf(stderr, "memcpy_to_vol_aligned(): destination pointer not aligned on %d byte boundary\n", sizeof(CPY_WORD));
-        _exit(1);
-    }
-    if( ((uint64_t)src & CPY_TEST_MASK))
-    {
-        fprintf(stderr, "memcpy_to_vol_aligned(): source pointer not aligned on %d byte boundary\n", sizeof(CPY_WORD));
-        _exit(1);
-    }
-    if(len & CPY_TEST_MASK)
-    {
-        fprintf(stderr, "memcpy_to_vol_aligned(): buffer length not a multiple of %d.\n", sizeof(CPY_WORD));
-        _exit(1);
-    }
-
-    // source copied from gcc memcpy
-    size_t length_words = len / sizeof(CPY_WORD);
-    volatile CPY_WORD *d = dest;
-    const CPY_WORD *s = src;
-    while (length_words--)
-        *d++ = *s++;
-    return dest;
-}
-
-void * memcpy_from_vol(void *dest, const volatile void *src, size_t len)
-{
-    // source copied from gcc memcpy
-    char *d = dest;
-    volatile const char *s = src;
-    while (len--)
-        *d++ = *s++;
-    return dest;
-}
-
-volatile void * memcpy_vol_to_vol(volatile void *dest, const volatile void *src, size_t len)
-{
-    // source copied from gcc memcpy
-    volatile char *d = dest;
-    volatile const char *s = src;
-    while (len--)
-        *d++ = *s++;
-    return dest;
-}
diff --git a/src/gds/awgtpman/shared_memory.h b/src/gds/awgtpman/shared_memory.h
index 8dfe24911..099d0ea24 100644
--- a/src/gds/awgtpman/shared_memory.h
+++ b/src/gds/awgtpman/shared_memory.h
@@ -19,38 +19,4 @@ extern volatile AWG_DATA *shmemAwgData;
 int OpenAwgDataSharedMemory(const char *model_name);
 
 
-// helper functions for volatile pointers
-
-/**
- * Copy to a volatile pointer from a regular pointer.
- * Destination and source must be aligned on 8 byte boundaries
- * @param dest The destination pointer.  Should be volatile.
- * @param src The source pointer.
- * @param len Number of bytes to copy.
- * @return The destination pointer.
- */
-volatile void *
-memcpy_to_vol_aligned(volatile void *dest, const void *src, size_t len);
-
-/**
- * Copy to a regular pointer from a volatile pointer.
- * Works the same as memcpy()
- * @param dest Destination pointer.
- * @param src  Source pointer.  Must be volatile.
- * @param len  Number of bytes to copy.
- * @return  destination pointer.
- */
-void * memcpy_from_vol(void *dest, const volatile void *src, size_t len);
-
-/**
- * Copy to a volatile pointer from a volatile pointer.
- * Works the same as memcpy()
- * @param dest The destination pointer.  Must be volatile.
- * @param src The source pointer.  Must be volatile.
- * @param len Number of bytes to copy.
- * @return The destination pointer.
- */
-volatile void * memcpy_vol_to_vol(volatile void *dest, const volatile void *src, size_t len);
-
-
 #endif // DAQD_TRUNK_SHARED_MEMORY_H
-- 
GitLab