-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate unit_tests/04_shared_memory
There were two tests in this directory using the same .cpp file, but different mlir files. Unfortunately, in the current flow, this means that the result products of these tests collide. As a quick solution, separate these into different directories. Along the way, fix a latent bug in the 'row' version.
- Loading branch information
1 parent
9ccfcdd
commit c49db4f
Showing
2 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//===- test.cpp -------------------------------------------------*- C++ -*-===// | ||
// | ||
// This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
// (c) Copyright 2020 Xilinx Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "test_library.h" | ||
#include <cassert> | ||
#include <cmath> | ||
#include <cstdio> | ||
#include <cstring> | ||
#include <fcntl.h> | ||
#include <stdlib.h> | ||
#include <sys/mman.h> | ||
#include <thread> | ||
#include <unistd.h> | ||
#include <xaiengine.h> | ||
|
||
#define LOCK_TIMEOUT 100 | ||
|
||
#include "aie_inc.cpp" | ||
|
||
int main(int argc, char *argv[]) { | ||
printf("test start.\n"); | ||
|
||
aie_libxaie_ctx_t *_xaie = mlir_aie_init_libxaie(); | ||
mlir_aie_init_device(_xaie); | ||
|
||
mlir_aie_clear_tile_memory(_xaie, 1, 3); | ||
mlir_aie_clear_tile_memory(_xaie, 1, 4); | ||
|
||
mlir_aie_configure_cores(_xaie); | ||
mlir_aie_configure_switchboxes(_xaie); | ||
mlir_aie_configure_dmas(_xaie); | ||
mlir_aie_initialize_locks(_xaie); | ||
|
||
int errors = 0; | ||
|
||
printf("Acquire input buffer lock first.\n"); | ||
// Should this part of setup??? | ||
if (mlir_aie_acquire_input_lock(_xaie, 0, LOCK_TIMEOUT)) { | ||
errors++; | ||
printf("ERROR: timeout hit!\n"); | ||
} | ||
mlir_aie_write_buffer_a(_xaie, 3, 7); | ||
|
||
mlir_aie_check("Before", mlir_aie_read_buffer_a(_xaie, 3), 7, errors); | ||
mlir_aie_check("Before", mlir_aie_read_buffer_b(_xaie, 5), 0, errors); | ||
mlir_aie_check("Before", mlir_aie_read_buffer_c(_xaie, 5), 0, errors); | ||
|
||
mlir_aie_print_tile_status(_xaie, 1, 3); | ||
mlir_aie_print_tile_status(_xaie, 1, 4); | ||
|
||
printf("Starting cores\n"); | ||
mlir_aie_start_cores(_xaie); | ||
|
||
mlir_aie_check("Before and started", mlir_aie_read_buffer_a(_xaie, 3), 7, | ||
errors); | ||
mlir_aie_check("Before and started", mlir_aie_read_buffer_b(_xaie, 5), 0, | ||
errors); | ||
mlir_aie_check("Before and started", mlir_aie_read_buffer_c(_xaie, 5), 0, | ||
errors); | ||
|
||
printf("Release input buffer lock.\n"); | ||
mlir_aie_release_input_lock(_xaie, 1, 0); | ||
printf("Waiting to acquire output lock for read ...\n"); | ||
if (mlir_aie_acquire_output_lock(_xaie, 1, LOCK_TIMEOUT)) { | ||
errors++; | ||
printf("ERROR: timeout hit!\n"); | ||
} | ||
|
||
mlir_aie_print_tile_status(_xaie, 1, 3); | ||
mlir_aie_print_tile_status(_xaie, 1, 4); | ||
|
||
mlir_aie_check("After", mlir_aie_read_buffer_a(_xaie, 3), 7, errors); | ||
mlir_aie_check("After", mlir_aie_read_buffer_b(_xaie, 5), 35, errors); | ||
mlir_aie_check("After", mlir_aie_read_buffer_c(_xaie, 5), 175, errors); | ||
|
||
int res = 0; | ||
if (!errors) { | ||
printf("PASS!\n"); | ||
res = 0; | ||
} else { | ||
printf("Fail!\n"); | ||
res = -1; | ||
} | ||
mlir_aie_deinit_libxaie(_xaie); | ||
|
||
printf("test done.\n"); | ||
return res; | ||
} |