Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Applications/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2022-2026 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -44,6 +44,10 @@ add_subdirectory(histogram)
add_subdirectory(prefix_sum)
add_subdirectory(optical_flow)

if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd")
add_subdirectory(pqc_trustflow_rocm)
endif()

if(NOT CXX_FS_HEADER_FOUND)
message(WARNING "filesystem not found, not building fdtd example")
else()
Expand Down
5 changes: 3 additions & 2 deletions Applications/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2022-2026 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -37,7 +37,8 @@ endif

ifneq ($(GPU_RUNTIME), CUDA)
EXAMPLES += \
monte_carlo_pi
monte_carlo_pi \
pqc_trustflow_rocm
endif

all: $(EXAMPLES)
Expand Down
9 changes: 9 additions & 0 deletions Applications/pqc_trustflow_rocm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
applications_pqc_*
kem_ct.bin
kem_pk.bin
kem_sk.bin
message.sig
receiver_ss.bin
sender_ss.bin
sig_pk.bin
sig_sk.bin
86 changes: 86 additions & 0 deletions Applications/pqc_trustflow_rocm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# MIT License
#
# Copyright (c) 2026 firedoil
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

set(example_prefix applications_pqc)

cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(${example_prefix} LANGUAGES CXX)

include(CTest)

include("${CMAKE_CURRENT_LIST_DIR}/../../Common/HipPlatform.cmake")
select_gpu_language()

enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD 17)
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
select_hip_platform()
verify_hip_platform(PLATFORMS amd)

option(
ROCM_EXAMPLES_PQC_BUILD_ALL_VARIANTS
"Build every supported PQC parameter set"
OFF
)

function(add_pqc_example target source algorithm parameter_mode)
add_executable(${target} ${source})
target_compile_definitions(
${target}
PRIVATE ALGORITHM=${algorithm} PARAM_MODE=${parameter_mode}
)
set_source_files_properties(
${source}
PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE}
)
if(BUILD_TESTING)
add_test(NAME ${target} COMMAND ${target} --self-test)
set_tests_properties(${target} PROPERTIES TIMEOUT 60)
endif()
install(TARGETS ${target})
endfunction()

function(add_pqc_signature_example target algorithm parameter_mode)
add_pqc_example(${target} sig_api/main.hip ${algorithm} ${parameter_mode})
target_compile_definitions(
${target}
PRIVATE BATCH_KEYGEN_SAMPLE_SPLIT_FAST=1
)
endfunction()

add_pqc_example(${example_prefix}_kyber768 kem_api/main.hip 1 3)
add_pqc_example(${example_prefix}_aigis_enc3 kem_api/main.hip 2 3)
add_pqc_signature_example(${example_prefix}_mldsa65 1 3)
add_pqc_signature_example(${example_prefix}_aigis_sig2 2 2)

if(ROCM_EXAMPLES_PQC_BUILD_ALL_VARIANTS)
add_pqc_example(${example_prefix}_kyber512 kem_api/main.hip 1 2)
add_pqc_example(${example_prefix}_kyber1024 kem_api/main.hip 1 4)
add_pqc_example(${example_prefix}_aigis_enc1 kem_api/main.hip 2 1)
add_pqc_example(${example_prefix}_aigis_enc2 kem_api/main.hip 2 2)
add_pqc_example(${example_prefix}_aigis_enc4 kem_api/main.hip 2 4)
add_pqc_signature_example(${example_prefix}_mldsa44 1 2)
add_pqc_signature_example(${example_prefix}_mldsa87 1 5)
add_pqc_signature_example(${example_prefix}_aigis_sig1 2 1)
add_pqc_signature_example(${example_prefix}_aigis_sig3 2 3)
endif()
121 changes: 121 additions & 0 deletions Applications/pqc_trustflow_rocm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# MIT License
#
# Copyright (c) 2026 firedoil
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

GPU_RUNTIME ?= HIP
ROCM_PATH ?= /opt/rocm
HIPCXX ?= $(ROCM_PATH)/bin/hipcc

CXX_STD := c++17
ICXXFLAGS := -std=$(CXX_STD)
ICPPFLAGS :=
ILDFLAGS :=
ILDLIBS :=

ifneq ($(GPU_RUNTIME), HIP)
$(error This example currently supports only the AMD HIP platform)
endif

ifneq ($(HIP_PLATFORM),)
ifneq ($(HIP_PLATFORM), amd)
$(error This example currently supports only the AMD HIP platform)
endif
endif

ICXXFLAGS += $(CXXFLAGS)
ICPPFLAGS += $(CPPFLAGS)
ILDFLAGS += $(LDFLAGS)
ILDLIBS += $(LDLIBS)

DEFAULT_EXAMPLES := \
applications_pqc_kyber768 \
applications_pqc_aigis_enc3 \
applications_pqc_mldsa65 \
applications_pqc_aigis_sig2

KEM_EXAMPLES := \
applications_pqc_kyber512 \
applications_pqc_kyber768 \
applications_pqc_kyber1024 \
applications_pqc_aigis_enc1 \
applications_pqc_aigis_enc2 \
applications_pqc_aigis_enc3 \
applications_pqc_aigis_enc4

SIG_EXAMPLES := \
applications_pqc_mldsa44 \
applications_pqc_mldsa65 \
applications_pqc_mldsa87 \
applications_pqc_aigis_sig1 \
applications_pqc_aigis_sig2 \
applications_pqc_aigis_sig3

ALL_EXAMPLES := $(KEM_EXAMPLES) $(SIG_EXAMPLES)

applications_pqc_kyber512: ALGORITHM=1
applications_pqc_kyber512: PARAM_MODE=2
applications_pqc_kyber768: ALGORITHM=1
applications_pqc_kyber768: PARAM_MODE=3
applications_pqc_kyber1024: ALGORITHM=1
applications_pqc_kyber1024: PARAM_MODE=4
applications_pqc_aigis_enc1: ALGORITHM=2
applications_pqc_aigis_enc1: PARAM_MODE=1
applications_pqc_aigis_enc2: ALGORITHM=2
applications_pqc_aigis_enc2: PARAM_MODE=2
applications_pqc_aigis_enc3: ALGORITHM=2
applications_pqc_aigis_enc3: PARAM_MODE=3
applications_pqc_aigis_enc4: ALGORITHM=2
applications_pqc_aigis_enc4: PARAM_MODE=4
applications_pqc_mldsa44: ALGORITHM=1
applications_pqc_mldsa44: PARAM_MODE=2
applications_pqc_mldsa65: ALGORITHM=1
applications_pqc_mldsa65: PARAM_MODE=3
applications_pqc_mldsa87: ALGORITHM=1
applications_pqc_mldsa87: PARAM_MODE=5
applications_pqc_aigis_sig1: ALGORITHM=2
applications_pqc_aigis_sig1: PARAM_MODE=1
applications_pqc_aigis_sig2: ALGORITHM=2
applications_pqc_aigis_sig2: PARAM_MODE=2
applications_pqc_aigis_sig3: ALGORITHM=2
applications_pqc_aigis_sig3: PARAM_MODE=3

all: $(DEFAULT_EXAMPLES)

all-variants: $(ALL_EXAMPLES)

$(KEM_EXAMPLES): kem_api/main.hip $(wildcard kem_api/*.h) $(wildcard kem_api/*.hpp)
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) $(ILDFLAGS) \
-DALGORITHM=$(ALGORITHM) -DPARAM_MODE=$(PARAM_MODE) \
-o $@ $< $(ILDLIBS)

$(SIG_EXAMPLES): sig_api/main.hip $(wildcard sig_api/*.h) $(wildcard sig_api/*.hpp)
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) $(ILDFLAGS) \
-DALGORITHM=$(ALGORITHM) -DPARAM_MODE=$(PARAM_MODE) \
-DBATCH_KEYGEN_SAMPLE_SPLIT_FAST=1 \
-o $@ $< $(ILDLIBS)

test: $(DEFAULT_EXAMPLES)
@set -e; for example in $(DEFAULT_EXAMPLES); do ./$$example --self-test; done

clean:
$(RM) $(ALL_EXAMPLES)

.PHONY: all all-variants clean test
Loading