Skip to content

Commit 6089f1c

Browse files
committed
Rearrange cpp cmake package
1 parent a2fd760 commit 6089f1c

File tree

15 files changed

+26
-17
lines changed

15 files changed

+26
-17
lines changed

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ include_directories(${PYTHON_INCLUDE_DIRS})
2525

2626
add_library(
2727
fssprgcuda SHARED
28-
lib.cpp
29-
torchcsprng/kernels.cu
30-
torchcsprng/owcf.cu
31-
torchcsprng/aes.cu
28+
src/fssprgcuda.cpp
29+
src/torchcsprng/kernels.cu
30+
src/torchcsprng/owcf.cu
31+
src/torchcsprng/aes.cu
3232
)
3333
set_target_properties(fssprgcuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
34-
target_link_libraries(fssprgcuda "${TORCH_LIBRARIES}")
34+
target_include_directories(fssprgcuda PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
35+
target_link_libraries(fssprgcuda PRIVATE "${TORCH_LIBRARIES}")
3536
target_compile_options(fssprgcuda PRIVATE $<$<COMPILE_LANGUAGE: CUDA>: --expt-extended-lambda>)

include/fssprgcuda.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (C) myl7
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
#pragma once
5+
6+
#include <cstdint>
7+
8+
namespace fssprgcuda {
9+
10+
void matyas_meyer_oseas_aes128(uint8_t *buf, int64_t buf_size, const uint8_t *key);
11+
12+
} // namespace fssprgcuda

lib.h

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// Copyright (C) myl7
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
#include "lib.h"
4+
#include "fssprgcuda.h"
55
#include <torch/torch.h>
6+
#include "torchcsprng/kernels.cuh"
67

78
using torch::Tensor;
8-
9-
extern Tensor encrypt(Tensor buf, const uint8_t *key, size_t key_size, const std::string &cipher);
9+
using torch::csprng::cuda::encrypt;
1010

1111
constexpr size_t block_t_size = 16;
1212

13-
void csprng_matyas_meyer_oseas_aes128(uint8_t *buf, size_t buf_size, const uint8_t *key, size_t key_size) {
13+
namespace fssprgcuda {
14+
15+
void matyas_meyer_oseas_aes128(uint8_t *buf, size_t buf_size, const uint8_t *key, size_t key_size) {
1416
const auto input_size_bytes = buf_size;
1517
TORCH_CHECK(input_size_bytes % block_t_size == 0, "input size in bytes(", input_size_bytes,
1618
") is not a multiple of block size(", block_t_size, ")");
@@ -21,3 +23,5 @@ void csprng_matyas_meyer_oseas_aes128(uint8_t *buf, size_t buf_size, const uint8
2123

2224
const auto output = encrypt(input, key, key_size, "aes128");
2325
}
26+
27+
} // namespace fssprgcuda
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)