Skip to content

Commit

Permalink
Merge pull request #208 from DLTcollab/file-rename
Browse files Browse the repository at this point in the history
refactor: Rename files and FPGA related variables
  • Loading branch information
jserv committed Dec 3, 2019
2 parents ab92d82 + abcbead commit 26e64ce
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dcurl is written by:
Externel Source:
* src/pow_sse.c is derived from preliminary work of Shinya Yagyu.
* src/pow_cl.c and src/pow_kernel.cl are adopted from ccurl [1].
* src/pow_fpga_accel.c is derived from accelerator by LampaLab [2].
* src/pow_fpga.c is derived from accelerator by LampaLab [2].
* src/list.h is adopted from National Cheng Kung University, Taiwan.

[1] https://github.com/iotaledger/ccurl
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ endif

ifeq ("$(BUILD_JNI)","1")
OBJS += \
jni/iri-pearldiver-exlib.o
jni/iri_pearldiver_exlib.o
endif

ifeq ("$(BUILD_COMPAT)", "1")
OBJS += \
compat-ccurl.o
compat_ccurl.o
endif

ifeq ("$(BUILD_FPGA_ACCEL)","1")
OBJS += \
pow_fpga_accel.o
pow_fpga.o
endif

ifeq ("$(BUILD_REMOTE)", "1")
Expand All @@ -160,7 +160,7 @@ OBJS += \

WORKER_EXCLUDE_OBJS := remote_interface.o
ifeq ("$(BUILD_JNI)", "1")
WORKER_EXCLUDE_OBJS += jni/iri-pearldiver-exlib.o
WORKER_EXCLUDE_OBJS += jni/iri_pearldiver_exlib.o
endif
WORKER_OBJS := $(addprefix $(OUT)/worker-,$(filter-out $(WORKER_EXCLUDE_OBJS), $(OBJS)))
WORKER_CFLAGS := $(filter-out -DENABLE_REMOTE, $(CFLAGS))
Expand Down
6 changes: 3 additions & 3 deletions cppcheck_suppress
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
shiftTooManyBitsSigned:src/pow_avx.c:321

// The unused functions are for the ccurl compatibility
unusedFunction:src/compat-ccurl.c:18
unusedFunction:src/compat-ccurl.c:29
unusedFunction:src/compat-ccurl.c:34
unusedFunction:src/compat_ccurl.c:18
unusedFunction:src/compat_ccurl.c:29
unusedFunction:src/compat_ccurl.c:34

// The invoked functions of OpenCL are not checked correctly with CppCheck
unusedFunction:src/pow_kernel.cl:185
Expand Down
2 changes: 1 addition & 1 deletion jni/iri-pearldiver-exlib.c → jni/iri_pearldiver_exlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* "LICENSE" at the root of this distribution.
*/

#include "iri-pearldiver-exlib.h"
#include "iri_pearldiver_exlib.h"
#include <jni.h>
#include <stdint.h>
#include "../src/dcurl.h"
Expand Down
4 changes: 2 additions & 2 deletions mk/java.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $(OUT)/com/iota/iri/crypto/PearlDiver.java: $(OUT)/com/iota/iri/crypto
$(Q)$(CURL) -s -o $@ \
"https://github.com/raw/$(GITHUB_REPO)/$(PearlDriverSRC)"

$(OUT)/jni/iri-pearldiver-exlib.h: $(OUT)/com/iota/iri/crypto/PearlDiver.java
$(OUT)/jni/iri_pearldiver_exlib.h: $(OUT)/com/iota/iri/crypto/PearlDiver.java
$(VECHO) " JAVAH\t$@\n"
$(Q)$(JAVAH) -classpath $(OUT) -o $@ com.iota.iri.crypto.PearlDiver

Expand All @@ -56,7 +56,7 @@ endif
CFLAGS_JNI += -I$(JAVA_HOME)/include
CFLAGS_JNI += -I$(OUT)/jni

jni/iri-pearldiver-exlib.c: $(OUT)/jni/iri-pearldiver-exlib.h
jni/iri_pearldiver_exlib.c: $(OUT)/jni/iri_pearldiver_exlib.h

$(OUT)/jni/%.o: jni/%.c
$(VECHO) " CC\t$@\n"
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/dcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "pow_cl.h"
#endif
#if defined(ENABLE_FPGA_ACCEL)
#include "pow_fpga_accel.h"
#include "pow_fpga.h"
#endif
#if defined(ENABLE_REMOTE)
#include "remote_interface.h"
Expand Down Expand Up @@ -63,7 +63,7 @@ extern ImplContext PoWCL_Context;
#endif

#if defined(ENABLE_FPGA_ACCEL)
extern ImplContext PoWFPGAAccel_Context;
extern ImplContext PoWFPGA_Context;
#endif

#if defined(ENABLE_REMOTE)
Expand Down Expand Up @@ -100,7 +100,7 @@ bool dcurl_init()
#endif

#if defined(ENABLE_FPGA_ACCEL)
if (registerImplContext(&PoWFPGAAccel_Context)) {
if (registerImplContext(&PoWFPGA_Context)) {
runtimeCaps |= CAP_FPGA;
ret |= true;
}
Expand Down
52 changes: 26 additions & 26 deletions src/pow_fpga_accel.c → src/pow_fpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* "LICENSE" at the root of this distribution.
*/

#include "pow_fpga_accel.h"
#include "pow_fpga.h"
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
Expand Down Expand Up @@ -39,9 +39,9 @@
S[3] = (I >> 24) & 0xff; \
}

static bool PoWFPGAAccel(void *pow_ctx)
static bool PoWFPGA(void *pow_ctx)
{
PoW_FPGA_Accel_Context *ctx = (PoW_FPGA_Accel_Context *) pow_ctx;
PoW_FPGA_Context *ctx = (PoW_FPGA_Context *) pow_ctx;

int8_t fpga_out_nonce_trit[NONCE_TRITS_LENGTH];

Expand Down Expand Up @@ -125,10 +125,10 @@ static bool PoWFPGAAccel(void *pow_ctx)
return res;
}

static bool PoWFPGAAccel_Context_Initialize(ImplContext *impl_ctx)
static bool PoWFPGA_Context_Initialize(ImplContext *impl_ctx)
{
PoW_FPGA_Accel_Context *ctx =
(PoW_FPGA_Accel_Context *) malloc(sizeof(PoW_FPGA_Accel_Context));
PoW_FPGA_Context *ctx =
(PoW_FPGA_Context *) malloc(sizeof(PoW_FPGA_Context));
if (!ctx)
goto fail_to_malloc;

Expand Down Expand Up @@ -182,9 +182,9 @@ static bool PoWFPGAAccel_Context_Initialize(ImplContext *impl_ctx)
return false;
}

static void PoWFPGAAccel_Context_Destroy(ImplContext *impl_ctx)
static void PoWFPGA_Context_Destroy(ImplContext *impl_ctx)
{
PoW_FPGA_Accel_Context *ctx = (PoW_FPGA_Accel_Context *) impl_ctx->context;
PoW_FPGA_Context *ctx = (PoW_FPGA_Context *) impl_ctx->context;

close(ctx->in_fd);
close(ctx->out_fd);
Expand All @@ -199,50 +199,50 @@ static void PoWFPGAAccel_Context_Destroy(ImplContext *impl_ctx)
free(ctx);
}

static void *PoWFPGAAccel_getPoWContext(ImplContext *impl_ctx,
int8_t *trytes,
int mwm,
int threads)
static void *PoWFPGA_getPoWContext(ImplContext *impl_ctx,
int8_t *trytes,
int mwm,
int threads)
{
PoW_FPGA_Accel_Context *ctx = impl_ctx->context;
PoW_FPGA_Context *ctx = impl_ctx->context;
memcpy(ctx->input_trytes, trytes, TRANSACTION_TRYTES_LENGTH);
ctx->mwm = mwm;
ctx->indexOfContext = 0;

return ctx;
}

static bool PoWFPGAAccel_freePoWContext(ImplContext *impl_ctx, void *pow_ctx)
static bool PoWFPGA_freePoWContext(ImplContext *impl_ctx, void *pow_ctx)
{
return true;
}

static int8_t *PoWFPGAAccel_getPoWResult(void *pow_ctx)
static int8_t *PoWFPGA_getPoWResult(void *pow_ctx)
{
int8_t *ret = (int8_t *) malloc(sizeof(int8_t) * TRANSACTION_TRYTES_LENGTH);
if (!ret)
return NULL;
memcpy(ret, ((PoW_FPGA_Accel_Context *) pow_ctx)->output_trytes,
memcpy(ret, ((PoW_FPGA_Context *) pow_ctx)->output_trytes,
TRANSACTION_TRYTES_LENGTH);
return ret;
}

static PoW_Info PoWFPGAAccel_getPoWInfo(void *pow_ctx)
static PoW_Info PoWFPGA_getPoWInfo(void *pow_ctx)
{
return ((PoW_FPGA_Accel_Context *) pow_ctx)->pow_info;
return ((PoW_FPGA_Context *) pow_ctx)->pow_info;
}

ImplContext PoWFPGAAccel_Context = {
ImplContext PoWFPGA_Context = {
.context = NULL,
.description = "FPGA",
.bitmap = 0,
.num_max_thread = 1, // num_max_thread >= 1
.num_working_thread = 0,
.initialize = PoWFPGAAccel_Context_Initialize,
.destroy = PoWFPGAAccel_Context_Destroy,
.getPoWContext = PoWFPGAAccel_getPoWContext,
.freePoWContext = PoWFPGAAccel_freePoWContext,
.doThePoW = PoWFPGAAccel,
.getPoWResult = PoWFPGAAccel_getPoWResult,
.getPoWInfo = PoWFPGAAccel_getPoWInfo,
.initialize = PoWFPGA_Context_Initialize,
.destroy = PoWFPGA_Context_Destroy,
.getPoWContext = PoWFPGA_getPoWContext,
.freePoWContext = PoWFPGA_freePoWContext,
.doThePoW = PoWFPGA,
.getPoWResult = PoWFPGA_getPoWResult,
.getPoWInfo = PoWFPGA_getPoWInfo,
};
10 changes: 5 additions & 5 deletions src/pow_fpga_accel.h → src/pow_fpga.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
* "LICENSE" at the root of this distribution.
*/

#ifndef POW_FPGA_ACCEL_H_
#define POW_FPGA_ACCEL_H_
#ifndef POW_FPGA_H_
#define POW_FPGA_H_

#include <stdint.h>
#include "common.h"
#include "constants.h"

typedef struct _pow_fpga_accel_context PoW_FPGA_Accel_Context;
typedef struct _pow_fpga_context PoW_FPGA_Context;

struct _pow_fpga_accel_context {
struct _pow_fpga_context {
/* Management of Multi-thread */
int indexOfContext;
/* Arguments of PoW */
Expand All @@ -24,7 +24,7 @@ struct _pow_fpga_accel_context {
int mwm;
/* PoW-related information */
PoW_Info pow_info;
/* Device files for the PFGA accelerator*/
/* Device files for the FPGA accelerator*/
int ctrl_fd;
int in_fd;
int out_fd;
Expand Down
2 changes: 1 addition & 1 deletion tests/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "pow_cl.h"
#endif
#if defined(ENABLE_FPGA_ACCEL)
#include "pow_fpga_accel.h"
#include "pow_fpga.h"
#endif

#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions tests/test-pow.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern ImplContext PoWCL_Context;
#endif

#if defined(ENABLE_FPGA_ACCEL)
extern ImplContext PoWFPGAAccel_Context;
extern ImplContext PoWFPGA_Context;
#endif

const char *description[] = {
Expand Down Expand Up @@ -131,7 +131,7 @@ int main()
#endif

#if defined(ENABLE_FPGA_ACCEL)
PoWFPGAAccel_Context,
PoWFPGA_Context,
#endif
};
#if defined(ENABLE_STAT)
Expand Down

0 comments on commit 26e64ce

Please sign in to comment.