提交 a238b11f 编写于 作者: Y Yu Yang

Fix linux compile

上级 d9870c35
......@@ -104,9 +104,10 @@ function(link_paddle_exe TARGET_NAME)
${PROTOBUF_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${CBLAS_LIBS}
${CMAKE_DL_LIBS}
${INTERAL_LIBS}
${ZLIB_LIBRARIES})
${ZLIB_LIBRARIES}
${CMAKE_DL_LIBS}
)
if(WITH_PYTHON)
target_link_libraries(${TARGET_NAME}
......
......@@ -49,7 +49,7 @@ public:
*/
virtual void* alloc(size_t size) {
void* ptr;
posix_memalign(&ptr, 32ul, size);
CHECK_EQ(posix_memalign(&ptr, 32ul, size), 0);
CHECK(ptr) << "Fail to allocate CPU memory: size=" << size;
return ptr;
}
......
......@@ -38,7 +38,7 @@ static std::mt19937 RandomEngine(time(0));
inline static std::unique_ptr<float[]> NewVector(size_t len = VECTOR_LEN,
size_t align = ALIGN) {
float* ptr;
posix_memalign((void**)&ptr, align, len * sizeof(float));
CHECK_EQ(posix_memalign((void**)&ptr, align, len * sizeof(float)), 0);
return std::unique_ptr<float[]>(ptr);
}
......
......@@ -125,9 +125,11 @@ TEST_F(CommonTest, sgdUpdate) {
const size_t alignHeader[] = {0, 2, 3, 5, 7, 8};
for (auto& size : sizeVec_) {
real *gradientBuffer, *valueBuffer, *momentumBuffer;
posix_memalign((void**)&gradientBuffer, 32, sizeof(real) * size);
posix_memalign((void**)&valueBuffer, 32, sizeof(real) * size);
posix_memalign((void**)&momentumBuffer, 32, sizeof(real) * size);
CHECK_EQ(posix_memalign((void**)&gradientBuffer, 32, sizeof(real) * size),
0);
CHECK_EQ(posix_memalign((void**)&valueBuffer, 32, sizeof(real) * size), 0);
CHECK_EQ(posix_memalign((void**)&momentumBuffer, 32, sizeof(real) * size),
0);
for (size_t i = 0; i < size; i++) {
gradientBuffer[i] = 1.0;
......
......@@ -25,7 +25,7 @@ namespace paddle {
pid_t getTID() {
#if defined(__APPLE__) || defined(__OSX__)
pid_t tid = syscall(SYS_thread_selfid);
#elif defined(__LINUX__)
#else
#ifndef __NR_gettid
#define __NR_gettid 224
#endif
......
......@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/util/Locks.h"
#include "paddle/utils/Locks.h"
#include <semaphore.h>
#include <unistd.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册