@CrazyHenry
2018-04-20T14:50:18.000000Z
字数 1879
阅读 1224
hhhhfaiss
- Author:李英民 | Henry
- E-mail: li
_
yingmin@
outlookdot
com- Home: https://liyingmin.wixsite.com/henry
快速了解我: About Me
转载请保留上述引用内容,谢谢配合!
#include <iostream>
#include <string>
using std::cout;
using std::string;
using std::ends;
using std::endl;
int main()
{
string s = "HelloWorld";
cout<<s<<ends<<s<<endl;
return 0;
}
Makefile:
MAKEFILE_INC=../../makefile.inc
-include $(MAKEFILE_INC)
NVCCLDFLAGS = -Xcompiler \"-Wl,-rpath=../../:../../gpu/\" \
-L../.. -L../../gpu -lfaiss -lgpufaiss
LDFLAGS = -L../.. -Wl,-rpath=../.. -lfaiss
all: cpu gpu
cpu: 1-Flat 2-IVFFlat 3-IVFPQ HelloWorld
gpu: 4-GPU 5-Multiple-GPUs
1-Flat: 1-Flat.cpp ../../libfaiss.$(SHAREDEXT)
$(CXX) -o $@ $(CXXFLAGS) $< -I../../../ $(LDFLAGS)
2-IVFFlat: 2-IVFFlat.cpp ../../libfaiss.$(SHAREDEXT)
$(CXX) -o $@ $(CXXFLAGS) $< -I../../../ $(LDFLAGS)
3-IVFPQ: 3-IVFPQ.cpp ../../libfaiss.$(SHAREDEXT)
$(CXX) -o $@ $(CXXFLAGS) $< -I../../../ $(LDFLAGS)
4-GPU: 4-GPU.cpp ../../libfaiss.$(SHAREDEXT) ../../gpu/libgpufaiss.$(SHAREDEXT)
$(NVCC) $(NVCCFLAGS) -o $@ $< $(NVCCLDFLAGS) -I../../../
5-Multiple-GPUs: 5-Multiple-GPUs.cpp ../../libfaiss.$(SHAREDEXT) \
../../gpu/libgpufaiss.$(SHAREDEXT)
$(NVCC) $(NVCCFLAGS) -o $@ $< $(NVCCLDFLAGS) -I../../../
HelloWorld: HelloWorld.cpp ../../libfaiss.$(SHAREDEXT)
$(CXX) -o $@ $(CXXFLAGS) $< -I../../../ $(LDFLAGS)
../../libfaiss.$(SHAREDEXT):
cd ../../ && make libfaiss.$(SHAREDEXT)
../../gpu/libgpufaiss.$(SHAREDEXT):
cd ../../gpu/ && make libgpufaiss.$(SHAREDEXT)
clean:
rm -f 1-Flat 2-IVFFlat 3-IVFPQ 4-GPU 5-Multiple-GPUs HelloWorld
新建目录test:
在test目录下创建HelloWorld.cpp,写入代码:
在cpp目录下:
make HelloWorld
然后可执行程序会出现在test目录下:
在cpp目录下执行./test/HelloWorld
:
./test/HelloWorld
在cpp目录下 make clean
:
make clean
Makefile的修改:
添加:
HelloWorld: HelloWorld.cpp ../../libfaiss.$(SHAREDEXT)
$(CXX) -o $@ $(CXXFLAGS) $< -I../../../ $(LDFLAGS)
修改:
all: cpu gpu
cpu: 1-Flat 2-IVFFlat 3-IVFPQ test/HelloWorld
gpu: 4-GPU 5-Multiple-GPUs
修改:
clean:
rm -f 1-Flat 2-IVFFlat 3-IVFPQ 4-GPU 5-Multiple-GPUs test/HelloWorld
注意:建议Makefile的注释都只在行首打#