Commit 9958035f authored by Leonardo Solis's avatar Leonardo Solis
Browse files

added kernel-stringify support

parent c050ab5f
......@@ -2,7 +2,7 @@
initpop.txt
*.dlg
*.xml
input/2bxd/
input/albumin_dock/
ocladock.wiki/
# ===================
......
# ocladock Makefile
# OCLADock Makefile
# CPU config
INTEL_INCLUDE_PATH=$(INTELOCLSDKROOT)/include
......@@ -128,7 +128,10 @@ endif
all: odock
odock: $(SRC)
stringify:
./stringify_ocl_krnls.sh
odock: stringify $(SRC)
g++ $(SRC) $(CFLAGS) -lOpenCL -o$(BIN_DIR)/$(TARGET) $(DEV) $(NWI) $(OPT) $(DD) $(REP) $(KFLAGS)
clean:
......
No preview for this file type
This diff is collapsed.
......@@ -64,6 +64,7 @@
#define OPT_PROG INC KNWI REP KGDB
#include "performdocking.h"
#include "stringify.h"
int docking_with_gpu(const Gridinfo* mygrid,
/*const*/ float* cpu_floatgrids,
......@@ -98,8 +99,13 @@ filled with clock() */
cl_context context;
cl_command_queue command_queue;
#ifdef _WIN32
const char *filename = KRNL_FILE;
printf("\n%-40s %-40s\n", "Kernel source file: ", filename); fflush(stdout);
#else
printf("\n%-40s %-40s\n", "Kernel source used for development: ", "./device/calcenergy.cl"); fflush(stdout);
printf( "%-40s %-40s\n", "Kernel string used for building: ", "./host/inc/stringify.h"); fflush(stdout);
#endif
const char* options_program = OPT_PROG;
printf("%-40s %-40s\n", "Kernel compilation flags: ", options_program); fflush(stdout);
......@@ -136,10 +142,17 @@ filled with clock() */
if (createCommandQueue(context,device_id[0],&command_queue) != 0) return 1;
// Create program and kernel from source
#ifdef _WIN32
if (ImportSource(filename, name_k1, device_id, context, options_program, &kernel1) != 0) return 1;
if (ImportSource(filename, name_k2, device_id, context, options_program, &kernel2) != 0) return 1;
if (ImportSource(filename, name_k3, device_id, context, options_program, &kernel3) != 0) return 1;
if (ImportSource(filename, name_k4, device_id, context, options_program, &kernel4) != 0) return 1;
#else
if (ImportSource(calcenergy_ocl, name_k1, device_id, context, options_program, &kernel1) != 0) return 1;
if (ImportSource(calcenergy_ocl, name_k2, device_id, context, options_program, &kernel2) != 0) return 1;
if (ImportSource(calcenergy_ocl, name_k3, device_id, context, options_program, &kernel3) != 0) return 1;
if (ImportSource(calcenergy_ocl, name_k4, device_id, context, options_program, &kernel4) != 0) return 1;
#endif
// End of OpenCL Host Setup
// =======================================================================
......
#!/bin/bash
# kernel-header files
HEADER_DIR="./common"
IN_HEADER1=$HEADER_DIR/"defines.h"
IN_HEADER2=$HEADER_DIR/"calcenergy_basic.h"
echo " "
echo "Stringified input header-files: "
echo $IN_HEADER1
echo $IN_HEADER2
# kernel files
KERNEL_DIR="./device"
IN_KERNELm=$KERNEL_DIR/"calcenergy.cl"
IN_KERNEL1=$KERNEL_DIR/"kernel1.cl"
IN_KERNEL2=$KERNEL_DIR/"kernel2.cl"
IN_KERNELa=$KERNEL_DIR/"auxiliary_genetic.cl"
IN_KERNEL3=$KERNEL_DIR/"kernel3.cl"
IN_KERNEL4=$KERNEL_DIR/"kernel4.cl"
echo " "
echo "Stringified input kernel-files: "
echo $IN_KERNELm
echo $IN_KERNEL1
echo $IN_KERNEL2
echo $IN_KERNELa
echo $IN_KERNEL3
echo $IN_KERNEL4
# output file
OUT=host/inc/stringify.h
echo " "
echo "Stringified output file: "
echo $OUT
echo " "
# temporal file
TMP=$KERNEL_DIR/stringify_tmp
echo "// OCLADOCK: AUTOMATICALLY GENERATED FILE, DO NOT EDIT" >$TMP
echo "#ifndef STRINGIFY_H" >>$TMP
echo "#define STRINGIFY_H" >>$TMP
echo "const char *calcenergy_ocl =" >>$TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELm >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELa >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL3 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL4 >> $TMP
echo ";" >>$TMP
echo "#endif // End of STRINGIFY_H" >>$TMP
# remove "#include" lines
grep -v '#include' $TMP > $OUT
......@@ -41,10 +41,15 @@ int ImportSource(const char* filename,
{
cl_int err;
#ifdef _WIN32
// Create the compute program ONLINE
string sourceStr;
err = convertToString2(filename, sourceStr);
const char *source = sourceStr.c_str();
#else
// Added as kernel is stringified already
const char *source = filename;
#endif
// L30nardoSV
size_t sourceSize[] = { strlen(source) };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment