cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

dasboogieman
Journeyman III

Compiling MemtestCL

Hi Everyone

Just to preface, I am an absolute noob, I've recently looked in to OpenCl simply because there was a flaw in one of my favorite tools for profiling the health of the AMD GPU's VRAM array. It's been a steep learning curve since I'm still even grasping the basics of C.

Anyway, the app is called MemtestCl, the original version was copyrighted and distributed by the FAH team at Stanford. However, it's pretty much been forgotten in the sands of time and doesn't actually work on anything more recent than the Tahiti generation.

An ex-member of the FAH team by the name of iHaque posted a fix for the issue and brought the source code under Open Source. However, I haven't been successful in following his instructions on compiling .exe with Microsoft VS2013 and I can't seem to contact iHaque.

I'm looking to compile the code for a Windows 7 x64 environment.

This is the link to iHaque's Github ihaque/memtestCL · GitHub

Any help with the compilation would be very much appreciated.

Thank you

0 Likes
9 Replies
dipak
Big Boss

Hi,

As you've mentioned that you're unable to compile the project, and if the problem is related to OpenCL, please can you share what type of compilation error you are facing?

Regards,

0 Likes

Ok

I current have the AMD OpenCl SDK and VS2013 installed

iHaque provided a Makefile:

POPT_DIR=popt/win32

OPENCL_VENDOR=AMD # NV, NV64, AMD, AMD64

!if "$(OPENCL_VENDOR)" == "NV"

OPENCL_DIR="\CUDA"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib\OpenCL.lib

!endif

!if "$(OPENCL_VENDOR)" == "NV64"

OPENCL_DIR="\CUDA"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib64\OpenCL.lib

!endif

!if "$(OPENCL_VENDOR)" == "AMD"

OPENCL_DIR="\Program Files (x86)\AMD APP"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib\x86\OpenCL.lib

!endif

!if "$(OPENCL_VENDOR)" == "AMD64"

OPENCL_DIR="\Program Files (x86)\AMD APP"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib\x86_64\OpenCL.lib

!endif

LIBS=$(OPENCL_LIB) popt\win32\libpopt.lib Ws2_32.lib

INCLUDES=-I$(OPENCL_INC) -I$(POPT_DIR)

DEFINES=-DWINDOWS -DCURL_STATICLIB -D_CRT_SECURE_NO_DEPRECATE

CFLAGS=-MT -Ox -EHsc $(DEFINES) $(INCLUDES) # -MTd -Zi for debug, -MT -Ox for prod

CXX=cl

CPP=cl /E

all: memtestCL.exe

clean:

  del *.obj

  del *.clh

  del *.exe

xxd.exe: xxd.cpp

  $(CXX) xxd.cpp

memtestCL_kernels.clh: memtestCL_kernels.cl xxd.exe

  $(CPP) memtestCL_kernels.cl > memtestCL_kernels

  xxd -i memtestCL_kernels > memtestCL_kernels.clh

  del memtestCL_kernels

memtestCL_core.obj: memtestCL_core.cpp memtestCL_core.h memtestCL_kernels.clh

  $(CXX) $(CFLAGS) -c memtestCL_core.cpp

memtestCL.exe: memtestCL_core.obj memtestCL_cli.cpp

  $(CXX) $(CFLAGS) memtestCL_core.obj memtestCL_cli.cpp -link $(LIBS) -OUT:memtestCL.exe

Anyway, when I followed the nmake instructions using VS2013 CMD prompt with Admin privileges I get the following error in command prompt:

E:\>cd memtestclmaster

E:\memtestCLmaster>nmake -f Makefiles\Makefile.windows

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1

Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -MT -Ox -EHsc -DWINDOWS -DCURL_STATICLIB -D_CRT_SECURE_NO_DEPRECATE -

I"\Program Files (x86)\AMD APP"\include -Ipopt/win32 -c memtestCL_core.cpp

Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x86

Copyright (C) Microsoft Corporation.  All rights reserved.

memtestCL_core.cpp

e:\memtestclmaster\memtestCL_core.h(45) : fatal error C1083: Cannot open include

file: 'CL/opencl.h': No such file or directory

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0

\VC\BIN\cl.EXE"' : return code '0x2'

Stop.

E:\memtestCLmaster>

So I've come to the conclusion that either my AMD OpenCL resources are not organized correctly or the makefile references are out of date.

0 Likes

Hi ,

You are right. As per the latest APP SDK installation, the default OpenCL base folder (i.e. AMDAPPSDKROOT) is as follows:

C:\Program Files\AMD APP SDK\2.9                  (for 32-bit systems)

C:\Program Files (x86)\AMD APP SDK\2.9          (for 64-bit systems)

[please see AMD_APP_SDK_Installation_Notes.pdf for APP SDK 2.9]

So, you have to update the script accordingly [i.e. line: OPENCL_DIR="\Program Files (x86)\AMD APP"]. Hope this will solve your problem.

Regards,

I've modified the makefile to the following and it did pass the first hurdle

!if "$(OPENCL_VENDOR)" == "AMD"

OPENCL_DIR="\Program Files\AMD APP SDK\2.9"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib\x86\OpenCL.lib

!endif

!if "$(OPENCL_VENDOR)" == "AMD64"

OPENCL_DIR="\Program Files (x86)\AMD APP SDK\2.9"

OPENCL_INC=$(OPENCL_DIR)\include

OPENCL_LIB=$(OPENCL_DIR)\lib\x86_64\OpenCL.lib

!endif

There is now a new error though

E:\memtestCLmaster>nmake -f Makefiles\Makefile.windows

Microsoft (R) Program Maintenance Utility Version 12.00.21005.1

Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -MT -Ox -EHsc -DWINDOWS -DCURL_STATICLIB -D_CRT_SECURE_NO_DEPRECATE -

I"\Program Files\AMD APP SDK\2.9"\include -Ipopt/win32 -c memtestCL_core.cpp

Microsoft (R) C/C++ Optimizing Compiler Version 18.00.30501 for x64

Copyright (C) Microsoft Corporation.  All rights reserved.

memtestCL_core.cpp

e:\memtestclmaster\memtestCL_core.h(45) : fatal error C1083: Cannot open include

file: 'CL/opencl.h': No such file or directory

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0

\VC\BIN\x86_amd64\cl.EXE"' : return code '0x2'

Stop.

E:\memtestCLmaster>

0 Likes

The problem is because the include path for OpenCL header file [i.e. "-I path"] is not directing to OpenCL include folder.

The drive name (for example "C:" or "D:") is missing in the following line:

OPENCL_DIR="\Program Files\AMD APP SDK\2.9"

If system drive is C, it should be point to like this:

OPENCL_DIR="C:\Program Files\AMD APP SDK\2.9"


Please also check whether OPENCL_VENDOR value is properly set or not, otherwise it will try to access wrong folder.


Regards,


0 Likes

Ok

I'm getting closer. It seems that the original Makefile had all the OpenCL addresses wrong. I'm still getting the same Fatal error1083 though.

This is my modified makefile, I've tweaked the addresses and eliminated the NVIDIA section in case of conflicts:

POPT_DIR=E:\memtestCLmaster\popt\win32

OPENCL_VENDOR=AMD # AMD, AMD64

!if "$(OPENCL_VENDOR)" == "AMD"

OPENCL_DIR="C:\Program Files\AMD APP SDK\2.9"

OPENCL_INC=$(OPENCL_DIR)\include\CL\opencl.h

OPENCL_LIB=$(OPENCL_DIR)\lib\x86\OpenCL.lib

!endif

!if "$(OPENCL_VENDOR)" == "AMD64"

OPENCL_DIR="C:\Program Files (x86)\AMD APP SDK\2.9"

OPENCL_INC=$(OPENCL_DIR)\include\CL\opencl.h

OPENCL_LIB=$(OPENCL_DIR)\lib\x86_64\OpenCL.lib

!endif

LIBS=$(OPENCL_LIB) popt\win32\libpopt.lib Ws2_32.lib

INCLUDES=-I$(OPENCL_INC) -I$(POPT_DIR)

DEFINES=-DWINDOWS -DCURL_STATICLIB -D_CRT_SECURE_NO_DEPRECATE

CFLAGS=-MT -Ox -EHsc $(DEFINES) $(INCLUDES) # -MTd -Zi for debug, -MT -Ox for prod

CXX=cl

CPP=cl /E

all: memtestCL.exe

clean:

  del *.obj

  del *.clh

  del *.exe

xxd.exe: xxd.cpp

  $(CXX) xxd.cpp

memtestCL_kernels.clh: memtestCL_kernels.cl xxd.exe

  $(CPP) memtestCL_kernels.cl > memtestCL_kernels

  xxd -i memtestCL_kernels > memtestCL_kernels.clh

  del memtestCL_kernels

memtestCL_core.obj: memtestCL_core.cpp memtestCL_core.h memtestCL_kernels.clh

  $(CXX) $(CFLAGS) -c memtestCL_core.cpp

memtestCL.exe: memtestCL_core.obj memtestCL_cli.cpp

  $(CXX) $(CFLAGS) memtestCL_core.obj memtestCL_cli.cpp -link $(LIBS) -OUT:memtestCL.exe

This is the MemtestCl_core.h code snippet with the include

/*

* memtestCL_core.h

* Public API for core memory test functions for MemtestCL

* Includes functional and OO interfaces to GPU test functions.

*

* Author: Imran Haque, 2010

* Copyright 2010, Stanford University

*

* This file is licensed under the terms of the LGPL. Please see

* the COPYING file in the accompanying source distribution for

* full license terms.

*

*/

#ifndef _MEMTESTCL_CORE_H_

#define _MEMTESTCL_CORE_H_

#include <stdio.h>

#include <iostream>

#include <list>

using namespace std;

#if defined (WINDOWS) || defined (WINNV)

    #include <windows.h>

    inline unsigned int getTimeMilliseconds(void) {

        return GetTickCount();

    }

    #include <windows.h>

  #define SLEEPMS(x) Sleep(x)

#elif defined (LINUX) || defined (OSX)

    #include <sys/time.h>

    inline unsigned int getTimeMilliseconds(void) {

        struct timeval tv;

        gettimeofday(&tv,NULL);

        return tv.tv_sec*1000 + tv.tv_usec/1000;

    }

    #include <unistd.h>

    #define SLEEPMS(x) usleep(x*1000)

#else

    #error Must #define LINUX, WINDOWS, WINNV, or OSX

#endif

#if defined (__APPLE__) || defined(MACOSX) || defined(OSX)

   #include <OpenCL/opencl.h>

#else

   #include <CL/opencl.h>

#endif

cl_int softwaitForEvents(cl_uint num_events,const cl_event* event_list,cl_command_queue const* pcq=NULL,unsigned sleeplength=1,unsigned limit=15000);

const char* descriptionOfError (cl_int err);

typedef unsigned int uint;

I think that section of code I've highlighted is the culprit, I've tried to change it to the proper AMDSDK directory but it made no difference.

0 Likes

Hi,

I think, following section is okay:

#else

   #include <CL/opencl.h>

#endif


Instead, following line should point to OpenCL include directory, not the file:

OPENCL_INC=$(OPENCL_DIR)\include\CL\opencl.h

              ---->   OPENCL_INC=$(OPENCL_DIR)\include


Regards,

0 Likes

Hi

I made the changes but the error still exists.

Theres a piece of code somewhere that is pointing to the wrong include directory.

0 Likes

Hi,

Can't say what is the problem. But this this general way to include OpenCL header file (you can check OpenCL samples in APP SDK). If don't require any header files related to gl or ext, you can also use "CL/cl.h".

I've an another suggestion you can try out. Create a simple OpenCL project using C/C++ and include the OpenCL header file similar to this. Try to compile the project by providing header file include path via "-I" option same as this one and check whether you get the same error or not. If not, then the problem is related to build script.

Regards,

0 Likes